layui.define(['YsModal', 'table', 'YsMultyFile'], function (exports) {
	"use strict";
	var $ = layui.jquery,object = {
		c: {data:[]}, // 配置项
		f: function (c) { // 数据初始化
			var s = new Date().getTime(),t = this;
			t.c = c;
			
			console.log(c);
			
			// 计算表单高度
//			console.log('window.screen.height --整个屏幕的像素高度--', window.screen.height);
//			console.log('window.outerHeight --浏览器高度--', window.outerHeight);
//			console.log('window.innerHeight --浏览器显示高度--', window.innerHeight);
//			console.log('表单高度--', $('#' + t.c.id_form).height());
			var height_table = window.innerHeight - $('#' + c.formObj.c.id_form).height() - 150;
			t.c.height_table = height_table < 300 ? 300 : height_table;
		},
        load:function () { // 加载控件
			var t = this;

			// 给数据添加序号
			t.addIndexToData();

			var cols = [];
			cols = t.listenColByGridId(cols);

			// 创建渲染实例
			layui.table.render({
				elem: '#' + t.c.id_table_sub
				,toolbar: '#toolbar_in_form'
				,defaultToolbar: []
				,height: t.c.height_table // 
				,cellMinWidth: 95
				,totalRow: true // 开启合计行，true开启，false关闭
				,limit: 9999
				,even: false // 开启隔行背景
				,cols: cols
				,data: t.c.sonlist
				,done: function(res) {
					t.listenFormItem();
					t.listenFormItemByGridId();
					var rowspan = [];
					for(var i=0;i<t.c.colGridArr.length;i++){
					    if(t.c.colGridArr[i].isRowspan==1){
                            rowspan.push(t.c.colGridArr[i].field);
                        }
                    }
					if(rowspan!=null && rowspan.length>0){
                        t.layuiRowspan(rowspan, "0", true, rowspan[0]);
                    }
				}
				,error: function(res, msg){
					console.log(res, msg)
				}
			});

			// 监听按钮
			layui.YsSubGridBtn.init({
				gridId: t.c.gridId,
				id_table_sub_grid: t.c.id_table_sub,
				subGridObj: t
			});
        },
		listenFormItem: function() {
			var t = this;

			// 文本框编辑事件
			$('input[data-filter="_input_filter_text_on_sub_grid"]').on('change',function (e) {
				var table = layui.table;
				var value = $(this).val();
			    var tdElem = $(this).closest('td');
			    var field = tdElem.data('field');
			    var trElem = tdElem.closest('tr');
			    var tableView = trElem.closest('.layui-table-view');
			    var index = trElem.data('index');
			    // 表格框架数据同步
			    table.cache[t.c.id_table_sub][trElem.data('index')][field] = value;

			    // 表格数据同步
			    t.c.sonlist[index][field] = value;

			    console.log('value---', value);

				return;
			});

			// 绑定选择框(下拉)的值变化提交事件
			layui.form.on('select(_input_filter_selector_on_table_in_form)', function (data) {
				var table = layui.table;

			    var selectElem = $(data.elem);
			    var tdElem = selectElem.closest('td');
			    var field = tdElem.data('field');
			    var trElem = tdElem.closest('tr');
			    var tableView = trElem.closest('.layui-table-view');
			    layui.table.cache[tableView.attr('lay-id')][trElem.data('index')][tdElem.data('field')] = data.value;
			    var index = trElem.data('index');

			    // 表格框架数据同步
			    table.cache[t.c.id_table_sub][trElem.data('index')][field] = data.value;

			    // 表格数据同步
			    t.c.sonlist[index][field] = data.value;

			    return;
			});
			
			// 绑定选择框(转换)的值变化提交事件
			layui.form.on('switch(_input_filter_checkbox_on_sub_grid)', function(data){
				//layer.tips(this.value + ' ' + this.name + '：'+ data.elem.checked, data.othis);
				var value = this.checked ? 1 : 0;

			    var table = layui.table;
			    var switchElem = $(data.elem);
			    var tdElem = switchElem.closest('td');
			    var field = tdElem.data('field');
			    var trElem = tdElem.closest('tr');
			    var tableView = trElem.closest('.layui-table-view');
			    table.cache[tableView.attr('lay-id')][trElem.data('index')][tdElem.data('field')] = value;
			    var index = trElem.data('index');

			    // 表格框架数据同步
			    table.cache[t.c.id_table_sub][trElem.data('index')][field] = value;

			    // 表格数据同步
			    t.c.sonlist[index][field] = value;
			});

			// 初始化YYYY-MM
			$('input[data-filter="_input_filter_date_yyyymm_on_sub_grid"]').each(function(index, domEle){

			    var tdElem = $(this).closest('td');
			    var trElem = tdElem.closest('tr');
			    var index = trElem.data('index');
			    var field = tdElem.data('field');

				layui.laydate.render({
					elem: this
					, type: 'month'
					, calendar: true
					, btns: ['clear', 'confirm', 'now']
					, done: function (value, date) {

					    // 表格框架数据同步
						layui.table.cache[t.c.id_table_sub][trElem.data('index')][field] = value;

					    // 表格数据同步
					    t.c.sonlist[index][field] = value;
					}
				});
			})

			// 初始化YYYY-MM-DD
			$('input[data-filter="_input_filter_date_day_on_sub_grid"]').each(function(index, domEle){

			    var tdElem = $(this).closest('td');
			    var trElem = tdElem.closest('tr');
			    var index = trElem.data('index');
			    var field = tdElem.data('field');

				layui.laydate.render({
					elem: this
					, type: 'date'
					, calendar: true
					, btns: ['clear', 'confirm', 'now']
					, done: function (value, date) {

					    // 表格框架数据同步
						layui.table.cache[t.c.id_table_sub][trElem.data('index')][field] = value;

					    // 表格数据同步
					    t.c.sonlist[index][field] = value;
					}
				});
			})

			// 初始化弹出框
			$('input[data-filter="_input_filter_modal_single_on_sub_grid"]').each(function(index, domEle){
				var modalKey = $(this).attr('data-modal-key');
				var colCode = $(this).attr('name');

			    var tdElem = $(this).closest('td');
			    var trElem = tdElem.closest('tr');
			    var index = trElem.data('index');

				$(this).on('click',function (e) {
					t.showModal(modalKey, colCode, index);
				});
			})

			// 初始化图片
			$('img[data-filter="_input_filter_img_on_table_in_form"]').each(function(index, domEle){
				var dom = this;

			    var tdElem = $(this).closest('td');
			    var trElem = tdElem.closest('tr');
			    var index = trElem.data('index');

				var code = $(this).attr('code');

				layui.upload.render({
					elem: dom,
					url: t.c.urlUpload,
					multiple: false,
					progress: function(n, elem){
						//dom.val(n + '%');
					},
					done: function(res){
						if (res.code == 0) {
							var urlImg = res.data.filePath;
							t.c.sonlist[index][code] = urlImg;
							t.reloadGrid();
						}
					}
				});
			});

			// 初始化图片移除
			$('i[data-filter="_icon_remove_filter_img_on_table_in_form"]').on('click',function (e) {
				var dom = this;

			    var tdElem = $(this).closest('td');
			    var trElem = tdElem.closest('tr');
			    var index = trElem.data('index');

				var code = $(this).attr('code');

				t.c.sonlist[index][code] = '';
				t.reloadGrid();
			});

			// 初始化单文件
			$('img[data-filter="_input_filter_file_single_on_table_in_form"]').each(function(index, domEle){
				var dom = this;

			    var tdElem = $(this).closest('td');
			    var trElem = tdElem.closest('tr');
			    var index = trElem.data('index');

				var code = $(this).attr('code');

				layui.upload.render({
					elem: dom,
					url: t.c.urlUpload,
					multiple: false,
					accept: 'file',
					progress: function(n, elem){
						//dom.val(n + '%');
					},
					done: function(res){
						if (res.code == 0) {
							var urlFile = res.data.filePath;
							t.c.sonlist[index][code] = urlFile;
							t.reloadGrid();
						}
					}
				});
			});

			// 初始化单文件移除
			$('i[data-filter="_icon_remove_filter_file_single_on_table_in_form"]').on('click',function (e) {
				var dom = this;

			    var tdElem = $(this).closest('td');
			    var trElem = tdElem.closest('tr');
			    var index = trElem.data('index');

				var code = $(this).attr('code');

				t.c.sonlist[index][code] = '';
				t.reloadGrid();
			});

			// 初始化单文件下载
			$('i[data-filter="_icon_download_filter_file_single_on_table_in_form"]').on('click',function (e) {
				var dom = this;

			    var tdElem = $(this).closest('td');
			    var trElem = tdElem.closest('tr');
			    var index = trElem.data('index');

				var code = $(this).attr('code');

				window.open(t.c.sonlist[index][code]);
			});

			// 初始化多文件
			$('input[data-filter="_input_filter_file_multy_on_table_in_form"]').on('click',function (e) {
				var dom = this;

			    var tdElem = $(this).closest('td');
			    var trElem = tdElem.closest('tr');
			    var index = trElem.data('index');

				var code = $(this).attr('code');

				var btnDisable = false;
				layui.YsMultyFile.init({dom: dom, btnDisable: btnDisable, extraParam:{index: index, code: code, usePlace: 'subGrid', parentObj: t}});
			});
		},

		//当子列表的pc需要来回切换的时候
		listenColByGridId: function(cols) {
			var t = this;

			if (t.c.gridId == 29) {
				var domForm = $('#' + t.c.formObj.c.id_form);
				var paymentReturnType = domForm.find('select[name="paymentReturnType"]').val();
				//初始化编辑的字段
				var colNew = [];
                if (paymentReturnType == 1) {
                    for (let i = 0; i < t.c.colGridArr.length; i++) {
                        let coll = t.c.colGridArr[i];
                        if (coll.modalValueCode == 'vyhzhmc'){
                            coll.templet = null;
                        }
                        colNew.push(coll)
                    }
                } else {
                    for (let i = 0; i < t.c.colGridArr.length; i++) {
                        let coll = t.c.colGridArr[i];
                        if (coll.modalValueCode == 'vyhzhmc'){
                            coll.templet ="#templet_script_sub_grid_13113";
                        }
                        if (coll.modalValueCode != 'tkVyhzh'
                            && coll.modalValueCode != 'tkVyhzhmc'
                            && coll.modalValueCode != 'tkVid'
                            && coll.modalValueCode != 'tkVkhh'
                            && coll.modalValueCode != 'refundableAmount'
                            && coll.modalValueCode != 'operateCompanyPrepaymentId'
                        ){
                            colNew.push(t.c.colGridArr[i])
                        }
                    }
                }
				cols.push(colNew);
			}else if (t.c.gridId == 63) {//采购计划单
				var domForm = $('#' + t.c.formObj.c.id_form);
				var isJgSub = domForm.find('input[name="isJgSub"]').val();//是否加购子件

				//初始化编辑的字段
				var colNew = [];
				if (isJgSub == "0") {
					for (let i = 0; i < t.c.colGridArr.length; i++) {
						let coll = t.c.colGridArr[i];
						if (coll.field == 'jgSl'){
							coll.hide = true;

						}
						colNew.push(coll);
					}
				} else {
					for (let i = 0; i < t.c.colGridArr.length; i++) {
						let coll = t.c.colGridArr[i];
						if (coll.field == 'jgSl'){
							coll.hide = false;
						}
						colNew.push(coll)
					}
				}
				cols.push(colNew);
			} else {
				cols.push(t.c.colGridArr);
			}
			return cols;
		},

		listenFormItemByGridId: function() {
        	var t = this;

			if(t.c.gridId == 15) {
				t.listenFormItemByGridId15();
			} else if(t.c.gridId == 17) {//预支账户报销单
				t.listenFormItemByGridId17();
			} else if(t.c.gridId == 18) {
        		t.listenFormItemByGridId18();
        	} else if(t.c.gridId == 20) { // 预约调拨单详情
        		t.listenFormItemByGridId20();
        	} else if(t.c.gridId == 21) { // 资金登记单
				t.listenFormItemByGridId21();
			} else if(t.c.gridId == 23) { // 预付款认领单
				t.listenFormItemByGridId23();
			} else if(t.c.gridId == 25) { // 资金认领单
				t.listenFormItemByGridId25();
			}else if(t.c.gridId == 29) { // 预付款退回申请
				t.listenFormItemByGridId29();
			} else if(t.c.gridId == 35) { // 万里汇外币付款单
				t.listenFormItemByGridId35();
			} else if(t.c.gridId == 36) { // 万里汇预付款对账单
				t.listenFormItemByGridId36();
			} else if(t.c.gridId == 39) { // 手工分配单
				t.listenFormItemByGridId39();
			} else if(t.c.gridId == 41) { // 职能费用申请
				t.listenFormItemByGridId41();
			} else if(t.c.gridId == 42) { // 付款申请单
				t.listenFormItemByGridId42();
			} else if(t.c.gridId == 43) { // 财务交易类型子表
				t.listenFormItemByGridId43();
			} else if(t.c.gridId == 44) { // 费用结算返还单
				t.listenFormItemByGridId44();
			} else if(t.c.gridId == 45) { // 费用划拨单子表
				t.listenFormItemByGridId45();
			} else if(t.c.gridId == 46) { // 费用结算单子表
				t.listenFormItemByGridId46();
			} else if(t.c.gridId == 47) { // 采购合同单子表
				t.listenFormItemByGridId47();
			} else if(t.c.gridId == 49) { // 采购预入库子表
				t.listenFormItemByGridId49();
			} else if(t.c.gridId == 51) { // 预约采购子表
				t.listenFormItemByGridId51();
			} else if(t.c.gridId == 52) { // 发票预核销单子表
				t.listenFormItemByGridId52();
			} else if(t.c.gridId == 53) { // 采购付款单
				t.listenFormItemByGridId53();
			} else if(t.c.gridId == 58) { // 报关单
				t.listenFormItemByGridId58();
			} else if(t.c.gridId == 62) { // 公司账户资金转账
				t.listenFormItemByGridId62();
			} else if(t.c.gridId == 63) { // 采购计划
				t.listenFormItemByGridId63();
			}else if(t.c.gridId == 70) { // 线上采购退货单子表
				t.listenFormItemByGridId70();
			} else if(t.c.gridId == 71) { // 手工组装单
				t.listenFormItemByGridId71();
			}else if(t.c.gridId == 75) { // 货位转移单
				t.listenFormItemByGridId75();
			} else if(t.c.gridId == 65) { // 入账申请单
				t.listenFormItemByGridId65();
			} else if(t.c.gridId == 66) { // 费用划拨管理子表
				t.listenFormItemByGridId66();
			}  else if(t.c.gridId == 77) { // 库存入库子件
				t.listenFormItemByGridId77();
			} else if(t.c.gridId == 81) { // HW采购计划
				t.listenFormItemByGridId81();
			}else if(t.c.gridId == 78) { // FBA计划单
				t.listenFormItemByGridId78();
			}else if(t.c.gridId == 89) { // 物流付款单（关税费）
				t.listenFormItemByGridId89();
			}else if(t.c.gridId == 90) { // 物流付款单（物流费）
				t.listenFormItemByGridId90();
			}
		},


		listenFormItemByGridId15: function() {//预支台账明细
			var t = this;
			// 初始化输入框
			$('input[data-filter="_input_filter_text_on_sub_grid"]').on('change',function (e) {
				var field = $(this).attr('name');
				console.log(field + '---value---', $(this).val());
				if (field == 'unitPrice' || field == 'quantity' || field == 'proxyPrice') {//单价 、数量、 代理价

					var tdElem = $(this).closest('td');
					var trElem = tdElem.closest('tr');
					var index = trElem.data('index');
					var unitPrice = 0;
					var quantity = 0;
					var proxyPrice = 0;
					if(t.c.sonlist[index]['unitPrice']) unitPrice = t.c.sonlist[index]['unitPrice'];
					if(t.c.sonlist[index]['quantity']) quantity = t.c.sonlist[index]['quantity'];
					if(t.c.sonlist[index]['proxyPrice']) proxyPrice = t.c.sonlist[index]['proxyPrice'];

					var totalPrice = parseFloat(unitPrice) * parseFloat(quantity);
					var proxyTotalPrice = parseFloat(proxyPrice) * parseFloat(quantity);

					t.c.sonlist[index]['totalPrice'] = totalPrice.toFixed(2);
					t.c.sonlist[index]['proxyTotalPrice'] = proxyTotalPrice.toFixed(2);
					t.reloadGrid();
				}
			});

		},

		listenFormItemByGridId17: function() {
			var t = this;
			// 初始化输入框
			$('input[data-filter="_input_filter_text_on_sub_grid"]').on('change',function (e) {
				var field = $(this).attr('name');
				console.log(field + '---value---', $(this).val());
				if (field == 'unitPrice') {//监听

					var tdElem = $(this).closest('td');
					var trElem = tdElem.closest('tr');
					var index = trElem.data('index');

					//计算总金额
					var unitPrice = 0 ;//总金额
					if(t.c.sonlist!=null && t.c.sonlist.length>0){
						for(var i=0;i<t.c.sonlist.length;i++){
							if(t.c.sonlist[i].unitPrice){
								unitPrice = unitPrice+parseFloat(t.c.sonlist[i].unitPrice);
							}
						}
					}
					var domForm = $('#' + window.formObj.c.id_form);
					//回填总金额
					domForm.find('input[name="totalAmount"]').val(unitPrice.toFixed(2));
				}
			});

		},

		listenFormItemByGridId18: function() {
        	var t = this;

			// 初始化输入框
			$('input[data-filter="_input_filter_text_on_sub_grid"]').on('change',function (e) {
				var field = $(this).attr('name');

			    console.log(field + '---value---', $(this).val());

				if (field == 'quantity' || field == 'costPrice' ||  field == 'proxyPrice') {

				    var tdElem = $(this).closest('td');
				    var trElem = tdElem.closest('tr');
				    var index = trElem.data('index');
				    if(t.c.sonlist[index]['quantity'] && t.c.sonlist[index]['costPrice']) {
				    	t.c.sonlist[index]['totalPrice'] = parseInt(t.c.sonlist[index]['costPrice']) * parseInt(t.c.sonlist[index]['quantity']);
				    }
					if(t.c.sonlist[index]['quantity'] && t.c.sonlist[index]['proxyPrice']) {
						t.c.sonlist[index]['proxyTotalPrice'] = (parseInt(t.c.sonlist[index]['quantity']) * parseFloat(t.c.sonlist[index]['proxyPrice'])).toFixed(2);
					}
					t.reloadGrid();
				}
			});

		},
		listenFormItemByGridId20: function() {
        	var t = this;

			// 初始化弹出框
			$('input[data-filter="_input_filter_modal_single_on_sub_grid"]').each(function(index, domEle){
				var modalKey = $(this).attr('data-modal-key');
				var colCode = $(this).attr('name');
				if (colCode == 'vgsbmTo') return
				var tdElem = $(this).closest('td');
				var trElem = tdElem.closest('tr');
				var index = trElem.data('index');
				$(this).off('click');
				$(this).on('click',function (e) {
					var vgsbmTo = t.c.sonlist[index].vgsbmTo;
					if(vgsbmTo==undefined || vgsbmTo==null || vgsbmTo==''){
						layer.msg("请先选择调入公司！", { icon: 2 });
						return;
					}
					var vgsbmTo = t.c.sonlist[index].vgsbmTo;
					layui.YsModal.init({modalKey: modalKey, colCode: colCode, parentObj: t, extraData:{useIn: '_select_on_grid', index: index},
						sameCode: 'xx',pathGridRequest: '/api/inter/tccPreAllocatePublish/search2?publishVgsbm='+vgsbmTo});
				});
			});

			// 初始化输入框
			$('input[data-filter="_input_filter_text_on_sub_grid"]').on('change',function (e) {
				var field = $(this).attr('name');
				var tdElem = $(this).closest('td');
				var trElem = tdElem.closest('tr');
				var index = trElem.data('index');

				if(t.c.sonlist[index]['singlePrice'] && t.c.sonlist[index]['num']) {
					if (field == 'num') {
						if (t.c.sonlist[index]['num'] > t.c.sonlist[index]['mayDistributeNum']){
							layer.msg("调拨数量不允许大于可调拨数量", { icon: 2 });
							t.c.sonlist[index]['num'] = 0
						}

					}
					t.c.sonlist[index]['totalPrice'] = parseInt(t.c.sonlist[index]['singlePrice']) * parseInt(t.c.sonlist[index]['num']);
					t.reloadGrid();
				}
			});

		},

		listenFormItemByGridId21: function() {
			var t = this;
			// 初始化输入框
			$('input[data-filter="_input_filter_text_on_sub_grid"]').on('change',function (e) {
				var field = $(this).attr('name');
				console.log(field + '---value---', $(this).val());
				if (field == 'paymentAmount') {//监听

					var tdElem = $(this).closest('td');
					var trElem = tdElem.closest('tr');
					var index = trElem.data('index');

					//计算总金额
					var paymentAmount = 0 ;//总金额
					if(t.c.sonlist!=null && t.c.sonlist.length>0){
						for(var i=0;i<t.c.sonlist.length;i++){
							if(t.c.sonlist[i].paymentAmount){
								paymentAmount = paymentAmount+parseFloat(t.c.sonlist[i].paymentAmount);
							}
						}
					}
					var domForm = $('#' + window.formObj.c.id_form);
					//回填总金额
					domForm.find('input[name="totalAmount"]').val(paymentAmount.toFixed(2));
				}
			});

		},

		listenFormItemByGridId23: function() {
			var t = this;
			//$('input[data-filter="_input_filter_modal_single_on_sub_grid"]').off('click');
			// 初始化弹出框
			$('input[data-filter="_input_filter_modal_single_on_sub_grid"]').each(function(index, domEle){
				var modalKey = $(this).attr('data-modal-key');
				var colCode = $(this).attr('name');

				var tdElem = $(this).closest('td');
				var trElem = tdElem.closest('tr');
				var index = trElem.data('index');
				$(this).off('click');
				$(this).on('click',function (e) {
					var paymentTime = t.c.sonlist[index].paymentTime;
					var paymentAmount = t.c.sonlist[index].paymentAmount;
					console.log('sonlist',t.c.sonlist[index]);
					if(paymentTime==undefined || paymentTime==null || paymentTime==''){
						layer.msg("请先选择付款时间！", { icon: 2 });
						return;
					}
					if(paymentAmount==null || paymentAmount==''){
						layer.msg("请先填写付款金额！", { icon: 2 });
						return;
					}
					var vyhzhmc = t.c.sonlist[index].vyhzhmc;
					var vkhh = t.c.sonlist[index].vkhh;
					var vyhzh = t.c.sonlist[index].vyhzh;

					var paymentAmount = 0 ;//总金额
					if(t.c.sonlist!=null && t.c.sonlist.length>0){
						for(var i=0;i<t.c.sonlist.length;i++){
							if(t.c.sonlist[i].paymentAmount){
								paymentAmount = paymentAmount+parseFloat(t.c.sonlist[i].paymentAmount);
							}
						}
					}
					var domForm = $('#' + window.formObj.c.id_form);
					//回填总金额
					domForm.find('input[name="totalAmount"]').val(paymentAmount.toFixed(2));

					layui.YsModal.init({modalKey: modalKey, colCode: colCode, parentObj: t, extraData:{useIn: '_select_on_grid', index: index},
						conditionsDefault: [
							{code: 'CB.Vyhzhmc', value:vyhzhmc},//付款银行户名
							{code: 'CB.Vkhh', value:vkhh},//付款开户行
							{code: 'CB.Vyhzh', value:vyhzh},//付款银行账号
							{code: 'paymentTime', value:paymentTime},//付款时间
							{code: 'paymentAmount', value:paymentAmount}//付款金额
						], sameCode: 'xx'});

				});
			});
		},

		listenFormItemByGridId25: function() {//资金认领单
			var t = this;
			//$('input[data-filter="_input_filter_modal_single_on_sub_grid"]').off('click');
			// 初始化弹出框
			$('input[data-filter="_input_filter_modal_single_on_sub_grid"]').each(function(index, domEle){
				var modalKey = $(this).attr('data-modal-key');
				var colCode = $(this).attr('name');

				var tdElem = $(this).closest('td');
				var trElem = tdElem.closest('tr');
				var index = trElem.data('index');
				$(this).off('click');
				$(this).on('click',function (e) {
					if(colCode == 'capitalRegisterBid'){
						var paymentTime = t.c.sonlist[index].paymentTime;
						var paymentAmount = t.c.sonlist[index].paymentAmount;
						console.log('sonlist',t.c.sonlist[index]);
						if(paymentTime==undefined || paymentTime==null || paymentTime==''){
							layer.msg("请先选择付款时间！", { icon: 2 });
							return;
						}
						if(paymentAmount==null || paymentAmount==''){
							layer.msg("请先填写付款金额！", { icon: 2 });
							return;
						}
						var vyhzhmc = t.c.sonlist[index].vyhzhmc;
						var vkhh = t.c.sonlist[index].vkhh;
						var vyhzh = t.c.sonlist[index].vyhzh;

						var paymentAmount = 0 ;//总金额
						if(t.c.sonlist!=null && t.c.sonlist.length>0){
							for(var i=0;i<t.c.sonlist.length;i++){
								if(t.c.sonlist[i].paymentAmount){
									paymentAmount = paymentAmount+parseFloat(t.c.sonlist[i].paymentAmount);
								}
							}
						}
						var domForm = $('#' + window.formObj.c.id_form);
						//回填总金额
						domForm.find('input[name="totalAmount"]').val(paymentAmount.toFixed(2));

						layui.YsModal.init({modalKey: modalKey, colCode: colCode, parentObj: t, extraData:{useIn: '_select_on_grid', index: index},
							conditionsDefault: [
								{code: 'CB.Vyhzhmc', value:vyhzhmc},//付款银行户名
								{code: 'CB.Vkhh', value:vkhh},//付款开户行
								{code: 'CB.Vyhzh', value:vyhzh},//付款银行账号
								{code: 'paymentTime', value:paymentTime},//付款时间
								{code: 'paymentAmount', value:paymentAmount}//付款金额
							], sameCode: 'xx'});
					}else{
						t.showModal(modalKey, colCode, index);
					}


				});
			});

		},

		listenFormItemByGridId29: function() {//预付款退回申请
			var t = this;
			// 初始化弹出框
			$('input[data-filter="_input_filter_modal_single_on_sub_grid"]').each(function(index, domEle){
				var modalKey = $(this).attr('data-modal-key');
				var colCode = $(this).attr('name');

				var tdElem = $(this).closest('td');
				var trElem = tdElem.closest('tr');
				var index = trElem.data('index');
				$(this).off('click');
				$(this).on('click',function (e) {
					if(colCode == 'tkVyhzh'){
						var vgsbm = t.c.sonlist[index].vgsbm;
						if(vgsbm==undefined || vgsbm==null || vgsbm==''){
							layer.msg("运营公司编码不允许为空！", { icon: 2 });
							return;
						}
						var domForm = $('#' + window.formObj.c.id_form);
						var paymentReturnType = domForm.find('select[name="paymentReturnType"]').val();
						if (paymentReturnType == '0'){
							var vyhzh = t.c.sonlist[index].vyhzh;
							if(vyhzh==undefined || vyhzh==null || vyhzh==''){
								layer.msg("请先选择收款银行账户编码！", { icon: 2 });
								return;
							}
						}
						layui.YsModal.init({modalKey: modalKey, colCode: colCode, parentObj: t, extraData:{useIn: 'TCW_OperateCompanyPrepaymentThsq', index: index},
							 sameCode: 'xx',pathGridRequest: '/api/inter/tcwOperateCompanyPrepayment/searchForModalyyYfksq?vgsbm='+vgsbm});
					} else if(colCode == 'vyhzhmc'){
						var vgsbm = t.c.sonlist[index].vgsbm;
						if(vgsbm==undefined || vgsbm==null || vgsbm==''){
							layer.msg("运营公司编码不允许为空！", { icon: 2 });
							return;
						}
						layui.YsModal.init({modalKey: modalKey, colCode: colCode, parentObj: t, extraData:{useIn: '_select_on_grid', index: index},
							sameCode: 'xx',pathGridRequest: '/api/inter/thrOperateCompanyBankInfo/searchForModalYfksq?vgsbm='+vgsbm});
					} else if(colCode == 'vgsbm'){
						layui.YsModal.init({modalKey: modalKey, colCode: colCode, parentObj: t, extraData:{useIn: 'THR_OperateCompanyApplyTh', index: index},
							sameCode: 'xx',pathGridRequest: '/api/inter/thrOperateCompanyApply/searchForTh?'});
					}else{
						t.showModal(modalKey, colCode, index);
					}

				});
			});

		},
		listenFormItemByGridId35: function() {
        	var t = this;

			// 初始化输入框
			$('input[data-filter="_input_filter_text_on_sub_grid"]').on('change',function (e) {
				var field = $(this).attr('name');

			    var domForm = $('#' + window.formObj.c.id_form);
				var exchangeRate = parseFloat(domForm.find('input[name="exchangeRate"]').val()); // 计算汇率

				// 若金额变动，则计算外币总金额及CNY总金额
				if (field == 'amount') {
					if(exchangeRate) {
						var amountTotalLocal = 0;
						var amountTotalCny = 0;
						for (var i = 0; i < t.c.sonlist.length; i++) {
							var amount = parseFloat(t.c.sonlist[i]['amount']);
							if(amount) {
								amountTotalLocal = amountTotalLocal + amount;
								amountTotalCny = amountTotalCny + amount * exchangeRate;
							}
						}
						domForm.find('input[name="amountTotalLocal"]').val(amountTotalLocal);
						domForm.find('input[name="amountTotalCny"]').val(Math.round(amountTotalCny * 100) / 100);
					}
				}

				if(exchangeRate) {
					if (field == 'amount' || field == 'fee') {

					    var tdElem = $(this).closest('td');
					    var trElem = tdElem.closest('tr');
					    var index = trElem.data('index');
					    if(t.c.sonlist[index]['amount']) {
					    	t.c.sonlist[index]['amountCny'] = Math.round((parseFloat(t.c.sonlist[index]['amount']) + parseFloat(t.c.sonlist[index]['fee'])) * exchangeRate * 100) / 100;
					    	t.reloadGrid();
					    }
					}
				}
			});

		},
		listenFormItemByGridId36: function() {
        	var t = this;
			
			// 根据币种计算归集总金额
			var amountGuijiGbp = 0;
			var amountGuijiUsd = 0;
			var amountGuijiEur = 0;
			for (var i = 0; i < t.c.sonlist.length; i++) {
				var jyCurrencyCode = t.c.sonlist[i].jyCurrencyCode;
				var recordAmountGuiji = t.c.sonlist[i].recordAmountGuiji
				if(jyCurrencyCode == 'GBP') {
					amountGuijiGbp = amountGuijiGbp + recordAmountGuiji;
				} else if(jyCurrencyCode == 'USD') {
					amountGuijiUsd = amountGuijiUsd + recordAmountGuiji;
				} else if(jyCurrencyCode == 'EUR') {
					amountGuijiEur = amountGuijiEur + recordAmountGuiji;
				}
			}
		    var domForm = $('#' + t.c.formObj.c.id_form);
			domForm.find('input[name="amountGuijiGbp"]').val(Math.round(amountGuijiGbp * 100) / 100);
			domForm.find('input[name="amountGuijiUsd"]').val(Math.round(amountGuijiUsd * 100) / 100);
			domForm.find('input[name="amountGuijiEur"]').val(Math.round(amountGuijiEur * 100) / 100);

			// 初始化输入框
			$('input[data-filter="_input_filter_text_on_sub_grid"]').on('change',function (e) {
				var field = $(this).attr('name');
				

				// 根据币种计算归集总金额
				if (field == 'recordAmountGuiji') {
					
					var amountGuijiGbp = 0;
					var amountGuijiUsd = 0;
					var amountGuijiEur = 0;
					for (var i = 0; i < t.c.sonlist.length; i++) {
						var jyCurrencyCode = t.c.sonlist[i].jyCurrencyCode;
						var recordAmountGuiji = parseFloat(t.c.sonlist[i].recordAmountGuiji)
						if(jyCurrencyCode == 'GBP') {
							amountGuijiGbp = amountGuijiGbp + recordAmountGuiji;
						} else if(jyCurrencyCode == 'USD') {
							amountGuijiUsd = amountGuijiUsd + recordAmountGuiji;
						} else if(jyCurrencyCode == 'EUR') {
							amountGuijiEur = amountGuijiEur + recordAmountGuiji;
						}
					}
				    var domForm = $('#' + window.formObj.c.id_form);
					domForm.find('input[name="amountGuijiGbp"]').val(Math.round(amountGuijiGbp * 100) / 100);
					domForm.find('input[name="amountGuijiUsd"]').val(Math.round(amountGuijiUsd * 100) / 100);
					domForm.find('input[name="amountGuijiEur"]').val(Math.round(amountGuijiEur * 100) / 100);
				}
			});

		},
		listenFormItemByGridId39: function() {
        	var t = this;
			// 初始化弹出框
			$('input[data-filter="_input_filter_modal_single_on_sub_grid"]').each(function(index, domEle){
				var modalKey = $(this).attr('data-modal-key');
				var colCode = $(this).attr('name');
				var tdElem = $(this).closest('td');
				var trElem = tdElem.closest('tr');
				var index = trElem.data('index');
				$(this).off('click');
				$(this).on('click',function (e) {
					var domForm = $('#' + window.formObj.c.id_form);
					//回填总金额
					var vgsbm = domForm.find('input[name="vgsbm"]').val();
					var productCode = t.c.sonlist[index].productCode;
					var gdepot = t.c.sonlist[index].gdepot;
					var allocateDetailId = t.c.sonlist[index].allocateDetailId;
					layui.YsModal.init({modalKey: modalKey, colCode: colCode, parentObj: t, extraData:{useIn: '_select_on_grid', index: index},
						sameCode: 'xx',pathGridRequest: '/api/inter/tccStockControl/searchForModal?vgsbm='+vgsbm+'&productCode='+productCode+'&cck='+gdepot+'&allocateDetailId='+allocateDetailId});
				});
			});


			// 初始化输入框
			$('input[data-filter="_input_filter_text_on_sub_grid"]').on('change',function (e) {

				var field = $(this).attr('name');
				var value = $(this).val();
			    var tdElem = $(this).closest('td');
			    var trElem = tdElem.closest('tr');
			    var index = trElem.data('index');
				t.c.sonlist[index][field] = value;

				if (field == 'num' || field == 'singlePrice') {

				    if(t.c.sonlist[index]['singlePrice'] && t.c.sonlist[index]['num']) {

						// 分配数量不能高于待分配数量
						if (t.c.sonlist[index]['num'] >  t.c.sonlist[index]['mayNum']) {
							alert("分配数量不得高于未分配数量");
							t.c.sonlist[index]['num'] = 0;
							t.c.sonlist[index]['distributedTotalPrice'] = 0;
						} else if (t.c.sonlist[index]['num'] >  t.c.sonlist[index]['stockNumAll']) {
							alert("分配数量不得高于库存数量");
							t.c.sonlist[index]['num'] = 0;
							t.c.sonlist[index]['distributedTotalPrice'] = 0;
						}else{
							t.c.sonlist[index]['distributedTotalPrice'] = Math.round(t.c.sonlist[index]['num'] * t.c.sonlist[index]['singlePrice'] * 100) / 100;
						}

				    	
				    	t.reloadGrid();
				    }
				}
				
				
				var field = $(this).attr('name');
			});

		},
		listenFormItemByGridId41: function() {
			var t = this;
			// 初始化输入框
			$('input[data-filter="_input_filter_text_on_sub_grid"]').on('change',function (e) {
				var field = $(this).attr('name');
				if (field == 'recoverableAmount') {//监听10352

					var tdElem = $(this).closest('td');
					var trElem = tdElem.closest('tr');
					var index = trElem.data('index');

					//计算总金额
					var recoverableAmount = 0 ;//总金额
					if(t.c.sonlist!=null && t.c.sonlist.length>0){
						for(var i=0;i<t.c.sonlist.length;i++){
							if(t.c.sonlist[i].recoverableAmount){
								recoverableAmount = recoverableAmount+parseFloat(t.c.sonlist[i].recoverableAmount);
							}
						}
					}
					var domForm = $('#' + window.formObj.c.id_form);
					//回填总金额
					domForm.find('input[name="recoverableAmountTotal"]').val(recoverableAmount.toFixed(2));
				}
			});

		},

		listenFormItemByGridId42: function() {
			var t = this;
			// 初始化输入框
			$('input[data-filter="_input_filter_text_on_sub_grid"]').on('change',function (e) {
				var field = $(this).attr('name');
				if (field == 'paymentAmount') {//监听

					var tdElem = $(this).closest('td');
					var trElem = tdElem.closest('tr');
					var index = trElem.data('index');

					//计算总金额
					var paymentAmount = 0 ;//总金额
					if(t.c.sonlist!=null && t.c.sonlist.length>0){
						for(var i=0;i<t.c.sonlist.length;i++){
							if(t.c.sonlist[i].paymentAmount){
								paymentAmount = paymentAmount+parseFloat(t.c.sonlist[i].paymentAmount);
							}
						}
					}
					var domForm = $('#' + window.formObj.c.id_form);
					//回填总金额
					domForm.find('input[name="paymentAmountTotal"]').val(paymentAmount.toFixed(2));
				}
			});

		},
		listenFormItemByGridId43: function() {
			var t = this;
			// 初始化输入框
			$('input[data-filter="_input_filter_text_on_sub_grid"]').on('change',function (e) {

				var field = $(this).attr('name');
				var value = $(this).val();
				var tdElem = $(this).closest('td');
				var trElem = tdElem.closest('tr');
				var index = trElem.data('index');
				t.c.sonlist[index][field] = value;

				if (field == 'num' || field == 'singlePrice') {

					if(t.c.sonlist[index]['singlePrice'] && t.c.sonlist[index]['num']) {

						// 分配数量不能高于待分配数量
						var unDistributeNum = t.c.sonlist[index].allocateNum - t.c.sonlist[index].distributedNum - t.c.sonlist[index].canceledNum;
						if (t.c.sonlist[index]['num'] >  unDistributeNum) {
							alert("分配数量不得高于待分配数量");
							t.c.sonlist[index]['num'] = 0;
							t.c.sonlist[index]['distributeTotalPrice'] = 0;
							return;
						} else {
							t.c.sonlist[index]['distributeTotalPrice'] = Math.round(t.c.sonlist[index]['num'] * t.c.sonlist[index]['singlePrice'] * 100) / 100;
						}

						t.reloadGrid();
					}
				}


				var field = $(this).attr('name');


				// 若金额变动，则计算外币总金额及CNY总金额
				if (field == 'amount') {
					var domForm = $('#' + window.formObj.c.id_form);
					var exchangeRate = parseFloat(domForm.find('input[name="exchangeRate"]').val()); // 计算汇率
					if(exchangeRate) {
						var amountTotalLocal = 0;
						var amountTotalCny = 0;
						for (var i = 0; i < t.c.sonlist.length; i++) {
							var amount = parseInt(t.c.sonlist[i]['amount']);
							if(amount) {
								amountTotalLocal = amountTotalLocal + amount;
								amountTotalCny = amountTotalCny + amount * exchangeRate;
							}
						}
						domForm.find('input[name="amountTotalLocal"]').val(amountTotalLocal);
						domForm.find('input[name="amountTotalCny"]').val(amountTotalCny);
					}
				}
			});

		},

		listenFormItemByGridId45: function() {
			var t = this;
			// 初始化输入框
			$('input[data-filter="_input_filter_text_on_sub_grid"]').on('change',function (e) {
				var field = $(this).attr('name');
				if (field == 'amount') {//监听

					var tdElem = $(this).closest('td');
					var trElem = tdElem.closest('tr');
					var index = trElem.data('index');

					//计算总金额
					var amount = 0 ;//总金额
					if(t.c.sonlist!=null && t.c.sonlist.length>0){
						for(var i=0;i<t.c.sonlist.length;i++){
							if(t.c.sonlist[i].amount){
								amount = amount+parseFloat(t.c.sonlist[i].amount);
							}
						}
					}
					var domForm = $('#' + window.formObj.c.id_form);
					//回填总金额
					domForm.find('input[name="totalAmount"]').val(amount.toFixed(2));
				}
			});


			$('input[data-filter="_input_filter_modal_single_on_sub_grid"]').each(function(index, domEle){
				var modalKey = $(this).attr('data-modal-key');
				var colCode = $(this).attr('name');

				var tdElem = $(this).closest('td');
				var trElem = tdElem.closest('tr');
				var index = trElem.data('index');
				$(this).off('click');
				$(this).on('click',function (e) {
					var conditionsDefault=[];
					if (colCode=='baseInfoType') {
						var operationsAttributeout = t.c.sonlist[index].operationsAttributeout;
						var operationsAttributein = t.c.sonlist[index].operationsAttributein;
						if (operationsAttributeout == undefined || operationsAttributeout == null || operationsAttributeout == '') {
							layer.msg("划出运营属性！", {icon: 2});
							return;
						}
						if (operationsAttributein == undefined || operationsAttributein == null || operationsAttributein == '') {
							layer.msg("划入运营属性！", {icon: 2});
							return;
						}

						if(operationsAttributeout=='运营账户'&&operationsAttributein=='运营账户'){
							 conditionsDefault= [
								{code: 'vName', value: '运营服务'},//付款银行户名
								{code: 'vAccountName', value: '划拨费用'},//付款开户行
							]
						}


					}
					layui.YsModal.init({
						modalKey: modalKey,
						colCode: colCode,
						parentObj: t,
						extraData: {useIn: '_select_on_grid', index: index},
						conditionsDefault:conditionsDefault,
						sameCode: 'xx'
					});
				});

			});

		},

		listenFormItemByGridId44: function() {
			var t = this;
			// 初始化输入框
			$('input[data-filter="_input_filter_text_on_sub_grid"]').on('change',function (e) {
				var field = $(this).attr('name');
				if (field == 'returnAmount') {//监听

					var tdElem = $(this).closest('td');
					var trElem = tdElem.closest('tr');
					var index = trElem.data('index');

					//计算总金额
					var returnAmount = 0 ;//总金额
					if(t.c.sonlist!=null && t.c.sonlist.length>0){
						for(var i=0;i<t.c.sonlist.length;i++){
							if(t.c.sonlist[i].returnAmount){
								returnAmount = returnAmount+parseFloat(t.c.sonlist[i].returnAmount);
							}
						}
					}
					var domForm = $('#' + window.formObj.c.id_form);
					//回填总金额
					domForm.find('input[name="totalAmount"]').val(returnAmount.toFixed(2));
				}
			});

		},

		listenFormItemByGridId46: function() {
			var t = this;
			// 初始化输入框
			$('input[data-filter="_input_filter_text_on_sub_grid"]').on('change',function (e) {
				var field = $(this).attr('name');
				if (field == 'amount') {//监听

					var tdElem = $(this).closest('td');
					var trElem = tdElem.closest('tr');
					var index = trElem.data('index');

					//计算总金额
					var amount = 0 ;//总金额
					if(t.c.sonlist!=null && t.c.sonlist.length>0){
						for(var i=0;i<t.c.sonlist.length;i++){
							if(t.c.sonlist[i].amount){
								amount = amount+parseFloat(t.c.sonlist[i].amount);
							}
						}
					}
					var domForm = $('#' + window.formObj.c.id_form);
					//回填总金额
					domForm.find('input[name="totalAmount"]').val(amount.toFixed(2));
				}
			});

		},

		listenFormItemByGridId47: function() {
			var t = this;
			// 初始化输入框
			$('input[data-filter="_input_filter_text_on_sub_grid"]').on('change',function (e) {
				var field = $(this).attr('name');
				if (field == 'subPurchasePrice') {//子件采购单价监听

					var tdElem = $(this).closest('td');
					var trElem = tdElem.closest('tr');
					var index = trElem.data('index');
					if(t.c.sonlist[index]['subPurchaseNum'] && t.c.sonlist[index]['subPurchasePrice']) {
						//子件采购总价
						t.c.sonlist[index]['purchaseTotalPrice'] = (parseFloat(t.c.sonlist[index]['subPurchaseNum'])*parseFloat(t.c.sonlist[index]['subPurchasePrice'])).toFixed(2);
						t.reloadGrid();
					}
					//计算合同金额
					var contractAmount = 0 ;//合同金额
					if(t.c.sonlist!=null && t.c.sonlist.length>0){
						for(var i=0;i<t.c.sonlist.length;i++){
							if(t.c.sonlist[i].purchaseTotalPrice){
								contractAmount = contractAmount+parseFloat(t.c.sonlist[i].purchaseTotalPrice);
							}
						}
					}
					var domForm = $('#' + window.formObj.c.id_form);
					//回填合同金额
					domForm.find('input[name="contractAmount"]').val(contractAmount.toFixed(2));
				}
			});

		},
		listenFormItemByGridId49: function() {
			var t = this;
			// 初始化输入框
			$('input[data-filter="_input_filter_text_on_sub_grid"]').on('change',function (e) {
				var field = $(this).attr('name');
				if (field == 'preStorageNum') {//子件预入库监听
					var tdElem = $(this).closest('td');
					var trElem = tdElem.closest('tr');
					var index = trElem.data('index');
					if(t.c.sonlist[index]['preStorageNum']) {
						if (Number($(this).val())> Number(t.c.sonlist[index]['subNotStorageNum'])){
							layer.msg("输入数量不允许大于子件未入库数量!");
							t.c.sonlist[index]['preStorageNum'] = t.c.sonlist[index]['subNotStorageNum'];
						}
						t.reloadGrid();
					}
				}
			});

		},
		listenFormItemByGridId51: function() {
			var t = this;
			// 初始化输入框
			$('input[data-filter="_input_filter_text_on_sub_grid"]').on('change',function (e) {
				var field = $(this).attr('name');
				if (field == 'reserveNumber') {
					var tdElem = $(this).closest('td');
					var trElem = tdElem.closest('tr');
					var index = trElem.data('index');
					if(t.c.sonlist[index]['reserveNumber']) {
						var t2 =t.c.sonlist[index]['productCode'];
						for(var i=0;i<t.c.sonlist.length;i++){
							if(t.c.sonlist[i]['productCode']==t2){
								t.c.sonlist[i]['reserveNumber']=t.c.sonlist[index]['reserveNumber'];
								var subBomNumber=parseInt(t.c.sonlist[i]['subBomNumber']);
								var subReserveNumber=parseInt(t.c.sonlist[index]['reserveNumber'])*subBomNumber;
								t.c.sonlist[i]['subReserveNumber']=subReserveNumber;
								var subBomPrice=parseFloat(t.c.sonlist[i]['subBomPrice']);
								var subTotalPrice=parseFloat(subBomPrice*subReserveNumber)
								t.c.sonlist[i]['subTotalPrice']=subTotalPrice.toFixed(2);

							}
						}

						t.reloadGrid();
						var preAccount=0;
						for(var z=0;z<t.c.sonlist.length;z++){
							if(t.c.sonlist[z]['subTotalPrice']){
								var subTotalPrice=parseFloat(t.c.sonlist[z]['subTotalPrice']);
								preAccount+=subTotalPrice;

							}

						}
						var domForm = $('#' + window.formObj.c.id_form);
						domForm.find('input[name="preAccount"]').val(preAccount.toFixed(2));
					}
				}
			});

		},


		listenFormItemByGridId52: function() {//发票预核销单
			var t = this;
			// 初始化输入框
			$('input[data-filter="_input_filter_text_on_sub_grid"]').on('change',function (e) {
				var field = $(this).attr('name');
				if (field == 'offsetNum') {//监听发票本次核销数量
					var tdElem = $(this).closest('td');
					var trElem = tdElem.closest('tr');
					var index = trElem.data('index');
					if(t.c.sonlist[index]['offsetNum']) {
						var offsetNum = parseInt(t.c.sonlist[index]['offsetNum']);//发票本次核销数量
						var subPurchaseNum=parseInt(t.c.sonlist[index]['subPurchaseNum']);//子件采购数量
						var subWriteOffNum=parseInt(t.c.sonlist[index]['subWriteOffNum']);//子件已核销数量

						if (Number(t.c.sonlist[index]['offsetNum'])> Number(subPurchaseNum - subWriteOffNum)){
							layer.msg("发票本次核销数量数量不允许大于\"子件采购数量\"-\"子件已核销数量\"!");
							t.c.sonlist[index]['offsetNum'] = 0;
						}else{
							//本次核销金额 = 发票本次核销数量*子件采购单价
							var subPurchasePrice=parseFloat(t.c.sonlist[index]['subPurchasePrice']);
							var offsetAmount = (offsetNum * subPurchasePrice).toFixed(2);
							t.c.sonlist[index]['offsetAmount'] = offsetAmount;
						}

						t.reloadGrid();
					}
				}
				var offsetTotalAmount = 0 ;
				if(t.c.sonlist!=null && t.c.sonlist.length>0){
					for(var i=0;i<t.c.sonlist.length;i++){
						if(t.c.sonlist[i].offsetAmount){
							offsetTotalAmount = offsetTotalAmount+parseFloat(t.c.sonlist[i].offsetAmount);
						}
					}
				}
				var domForm = $('#' + window.formObj.c.id_form);
				//回填核销总额
				domForm.find('input[name="offsetTotalAmount"]').val(offsetTotalAmount.toFixed(2));
			});

		},

		listenFormItemByGridId53: function() {//采购付款单
			var t = this;
			// 初始化输入框
			$('input[data-filter="_input_filter_text_on_sub_grid"]').on('change',function (e) {
				var field = $(this).attr('name');
				if (field == 'subThisPaidNum') {//监听子件本次付款数量
					var tdElem = $(this).closest('td');
					var trElem = tdElem.closest('tr');
					var index = trElem.data('index');
					if(t.c.sonlist[index]['subThisPaidNum']) {
						var subThisPaidNum = parseInt(t.c.sonlist[index]['subThisPaidNum']);//发票本次付款数量
						var subPurchaseNum=parseInt(t.c.sonlist[index]['subPurchaseNum']);//子件采购数量
						var subPaidNum=parseInt(t.c.sonlist[index]['subPaidNum']);//子件已付款数量

						if (Number(subThisPaidNum)> Number(subPurchaseNum - subPaidNum)){
							layer.msg("子件本次付款数量不允许大于\"子件采购数量\"-\"子件已付款数量\"!");
							t.c.sonlist[index]['subThisPaidNum'] = 0;
						}

						t.reloadGrid();
					}
				}
				var purchasePrice = 0 ;
				var paidAmount = 0 ;
				var currentPaymentAmount = 0 ;
				if(t.c.sonlist!=null && t.c.sonlist.length>0){
					for(var i=0;i<t.c.sonlist.length;i++){
						if(t.c.sonlist[i].subThisPaidNum){
							purchasePrice = purchasePrice+parseFloat(t.c.sonlist[i].subPurchasePrice);
							//（子件已付款数量*子件采购单价）之和
							var subPurchasePrice=parseFloat(t.c.sonlist[i]['subPurchasePrice']);
							var subPaidAmount = (parseFloat(t.c.sonlist[i]['subPaidNum'])* subPurchasePrice).toFixed(2);
							paidAmount = paidAmount + parseFloat(subPaidAmount);
							//（子件本次付款数量*子件采购单价）之和
							var subThisPaidNum = (parseFloat(t.c.sonlist[i]['subThisPaidNum'])* subPurchasePrice).toFixed(2);
							currentPaymentAmount = currentPaymentAmount + parseFloat(subThisPaidNum);
						}
					}
				}
				var domForm = $('#' + window.formObj.c.id_form);
				//回填采购总价
				domForm.find('input[name="purchasePrice"]').val(purchasePrice.toFixed(2));
				//回填已付款金额
				domForm.find('input[name="paidAmount"]').val(paidAmount.toFixed(2));
				//回填本次付款总额
				domForm.find('input[name="currentPaymentAmount"]').val(currentPaymentAmount.toFixed(2));
			});

		},


		listenFormItemByGridId58: function() {//报关单
			var t = this;
			// 初始化输入框
			$('input[data-filter="_input_filter_text_on_sub_grid"]').on('change',function (e) {
				var field = $(this).attr('name');
				if (field == 'customsQuantity') {//监听本次报关数量
					var tdElem = $(this).closest('td');
					var trElem = tdElem.closest('tr');
					var index = trElem.data('index');

					if(t.c.sonlist[index]['customsQuantity']) {
						var customsQuantity = parseInt(t.c.sonlist[index]['customsQuantity']);//本次报关数量
						var invoiceSurplusNum = parseInt(t.c.sonlist[index]['invoiceSurplusNum']);//发票剩余报关数量

						if (Number(customsQuantity)> Number(invoiceSurplusNum)){
							layer.msg("本次报关数量不允许大于发票剩余报关数量!");
							t.c.sonlist[index]['customsQuantity'] = 0;
							t.reloadGrid();
							return;
						}

						//商品总重 = 商品单重*本次报关数量
						var goodsTotalWeight = 0;
						var singleWeight = t.c.sonlist[index]['singleWeight'];//商品单重
						if(singleWeight && customsQuantity){
							goodsTotalWeight = (parseFloat(singleWeight) * parseFloat(customsQuantity)).toFixed(2);
						}
						t.c.sonlist[index]['goodsTotalWeight'] = goodsTotalWeight;

						//销售单价 = 子件采购单价*1.02
						var saleUnitPrice = 0;
						var subPurchasePrice = t.c.sonlist[index]['subPurchasePrice'];//子件采购单价
						if(subPurchasePrice){
							saleUnitPrice = (parseFloat(subPurchasePrice) * 0.12).toFixed(2);
						}
						t.c.sonlist[index]['saleUnitPrice'] = saleUnitPrice;

						//销售总价 = 销售单价*本次报关数量
						var saleTotalPrice = 0;
						if(saleUnitPrice && customsQuantity){
							saleTotalPrice = (parseFloat(saleUnitPrice) * parseFloat(customsQuantity)).toFixed(2);
						}
						t.c.sonlist[index]['saleTotalPrice'] = saleTotalPrice;

						t.reloadGrid();
					}
				}
			});

		},

		listenFormItemByGridId62: function() {
			var t = this;
			// 初始化输入框
			$('input[data-filter="_input_filter_text_on_sub_grid"]').on('change',function (e) {
				var field = $(this).attr('name');
				if (field == 'amount') {//监听

					var tdElem = $(this).closest('td');
					var trElem = tdElem.closest('tr');
					var index = trElem.data('index');

					//计算总金额
					var amount = 0 ;//总金额
					if(t.c.sonlist!=null && t.c.sonlist.length>0){
						for(var i=0;i<t.c.sonlist.length;i++){
							if(t.c.sonlist[i].amount){
								amount = amount+parseFloat(t.c.sonlist[i].amount);
							}
						}
					}
					var domForm = $('#' + window.formObj.c.id_form);
					//回填总金额
					domForm.find('input[name="totalAmount"]').val(amount.toFixed(2));
				}
			});

		},

		listenFormItemByGridId63: function() {//采购计划
			var t = this;

			// 初始化输入框
			$('input[data-filter="_input_filter_text_on_sub_grid"]').on('change',function (e) {
				var field = $(this).attr('name');


				if (field == 'spAmount' || field == 'jgSl') {

					var tdElem = $(this).closest('td');
					var trElem = tdElem.closest('tr');
					var index = trElem.data('index');

					if (field == 'spAmount') {
						var spAmount = parseFloat(t.c.sonlist[index]['spAmount']);
						var spBm = t.c.sonlist[index]['spBm'];
						for(var i=0;i<t.c.sonlist.length;i++){
							if(spBm == t.c.sonlist[i]['spBm']){
								t.c.sonlist[i]['spAmount'] = spAmount;

								//计划采购数量 = 采购数量*子件数量
								var purchaseAmount = 0;
								if( spAmount && t.c.sonlist[i]['subAmount']) {
									purchaseAmount = (spAmount * parseFloat(t.c.sonlist[i]['subAmount'])).toFixed(2);
								}
								t.c.sonlist[i]['purchaseAmount'] = purchaseAmount;

								//子件总数 = 计划采购数量+子件加购数量
								var subTotalAmount = purchaseAmount;
								if(t.c.sonlist[i]['jgSl']){
									subTotalAmount = parseFloat((subTotalAmount+parseFloat(t.c.sonlist[i]['jgSl']))).toFixed(2);
								}
								t.c.sonlist[i]['subTotalAmount'] = subTotalAmount;

								//子件预估总价 = 子件预估单价*子件总数
								var subTotalPrice = 0;
								if(t.c.sonlist[i]['bprice']){
									subTotalPrice = (subTotalAmount * parseFloat(t.c.sonlist[i]['bprice'])).toFixed(2);
								}
								t.c.sonlist[i]['subTotalPrice'] = subTotalPrice;
							}

						}

					}

					if(field == 'jgSl'){
						//子件总数 = 计划采购数量+子件加购数量
						var subTotalAmount = 0;
						if(t.c.sonlist[index]['purchaseAmount']){
							subTotalAmount = parseFloat(t.c.sonlist[index]['purchaseAmount']);
						}
						if(t.c.sonlist[index]['jgSl']){
							subTotalAmount = (subTotalAmount+parseFloat(t.c.sonlist[index]['jgSl'])).toFixed(2);
						}
						t.c.sonlist[index]['subTotalAmount'] = subTotalAmount;

						//子件预估总价 = 子件预估单价*子件总数
						var subTotalPrice = 0;
						if(t.c.sonlist[index]['bprice']){
							subTotalPrice = (subTotalAmount * parseFloat(t.c.sonlist[index]['bprice'])).toFixed(2);
						}
						t.c.sonlist[index]['subTotalPrice'] = subTotalPrice;
					}


					//重新计算采购预估金额
					var totalPrice = 0 ;
					for(var i=0;i<t.c.sonlist.length;i++){
						if(t.c.sonlist[i].subTotalPrice){
							totalPrice = totalPrice+parseFloat(t.c.sonlist[i].subTotalPrice);
						}
					}
					var domForm = $('#' + window.formObj.c.id_form);
					//回填采购预估金额
					domForm.find('input[name="totalPrice"]').val(totalPrice.toFixed(2));

					t.reloadGrid();

				}
			});

		},

		listenFormItemByGridId65: function() {
			var t = this;
			// 初始化输入框
			$('input[data-filter="_input_filter_text_on_sub_grid"]').on('change',function (e) {
				var field = $(this).attr('name');
				if (field == 'entryAmount') {//监听

					var tdElem = $(this).closest('td');
					var trElem = tdElem.closest('tr');
					var index = trElem.data('index');

					//计算总金额
					var entryAmount = 0 ;//总金额
					if(t.c.sonlist!=null && t.c.sonlist.length>0){
						for(var i=0;i<t.c.sonlist.length;i++){
							if(t.c.sonlist[i].entryAmount){
								entryAmount = entryAmount+parseFloat(t.c.sonlist[i].entryAmount);
							}
						}
					}
					var domForm = $('#' + window.formObj.c.id_form);
					//回填总金额
					domForm.find('input[name="totalAmount"]').val(entryAmount.toFixed(2));
				}
			});

		},

		listenFormItemByGridId66: function() {
			var t = this;
			// 初始化输入框
			$('input[data-filter="_input_filter_text_on_sub_grid"]').on('change',function (e) {
				var field = $(this).attr('name');
				if (field == 'amount') {//监听

					var tdElem = $(this).closest('td');
					var trElem = tdElem.closest('tr');
					var index = trElem.data('index');

					//计算总金额
					var amount = 0 ;//总金额
					if(t.c.sonlist!=null && t.c.sonlist.length>0){
						for(var i=0;i<t.c.sonlist.length;i++){
							if(t.c.sonlist[i].amount){
								amount = amount+parseFloat(t.c.sonlist[i].amount);
							}
						}
					}
					var domForm = $('#' + window.formObj.c.id_form);
					//回填总金额
					domForm.find('input[name="totalAmount"]').val(amount.toFixed(2));
				}
			});

		},

		listenFormItemByGridId70: function() {//线上采购退货单
			var t = this;

			// 初始化输入框
			$('input[data-filter="_input_filter_text_on_sub_grid"]').on('change',function (e) {
				var field = $(this).attr('name');
				var tdElem = $(this).closest('td');
				var trElem = tdElem.closest('tr');
				var index = trElem.data('index');
				if (field == 'subRefundNum') {
					var isRefund = t.c.formObj.getValueByName("isRefund");
					var subRefundNum = parseInt(t.c.sonlist[index]['subRefundNum']);
					var subTotalAmount = parseInt(t.c.sonlist[index]['subTotalAmount']);
					var subStorageNum = parseInt(t.c.sonlist[index]['subStorageNum']);
					if (isRefund == '0') {
						//≤子件采购总数
						if (subRefundNum > subTotalAmount){
							layer.msg("本次子件退货数量不允许大于子件采购总数!");
							t.c.sonlist[index]['subRefundNum'] = 0;
							t.reloadGrid();
							return;
						}
					}else {
						//≤子件采购总数  ≤子件库存数量
						if (subRefundNum > subTotalAmount  || subRefundNum > subStorageNum){
							layer.msg("本次子件退货数量不允许大于子件采购总数或者子件库存数量!");
							t.c.sonlist[index]['subRefundNum'] = 0;
							t.reloadGrid();
							return;
						}
					}
					t.reloadGrid();
				}
			});

		},

		listenFormItemByGridId71: function() {//手工组装单
			var t = this;
			//$('input[data-filter="_input_filter_modal_single_on_sub_grid"]').off('click');
			// 初始化弹出框
			$('input[data-filter="_input_filter_modal_single_on_sub_grid"]').each(function(index, domEle){
				var modalKey = $(this).attr('data-modal-key');
				var colCode = $(this).attr('name');

				var tdElem = $(this).closest('td');
				var trElem = tdElem.closest('tr');
				var index = trElem.data('index');
				$(this).off('click');
				$(this).on('click',function (e) {

					var subCode = t.c.sonlist[index].subCode;
					layui.YsModal.init({modalKey: modalKey, colCode: colCode, parentObj: t, extraData:{useIn: '_select_on_grid', index: index},
						conditionsDefault: [
							{code: '_ys_subCode', value:subCode},//子件编码
						], sameCode: 'xx'});

				});
			});
		},

		listenFormItemByGridId75: function() {//货位转移单
			var t = this;
			// 初始化输入框
			$('input[data-filter="_input_filter_text_on_sub_grid"]').on('change',function (e) {
				var field = $(this).attr('name');
				var tdElem = $(this).closest('td');
				var trElem = tdElem.closest('tr');
				var index = trElem.data('index');
				if (field == 'transferNum') {
					var productNum = parseInt(t.c.sonlist[index]['productNum']);
					var transferNum = parseInt(t.c.sonlist[index]['transferNum']);
					if (Number(productNum) != 0) {
						//转移数量<=可用数量
						if (transferNum > productNum){
							layer.msg("本次转移数量数量不允许大于商品可用数量!");
							t.c.sonlist[index]['transferNum'] = 0;
							t.reloadGrid();
							return;
						}
					}
				}
			});
		},


		listenFormItemByGridId77: function() {
			var t = this;
			// 初始化输入框
			$('input[data-filter="_input_filter_text_on_sub_grid"]').on('change',function (e) {
				var field = $(this).attr('name');
				if (field == 'amount') {//监听

					var tdElem = $(this).closest('td');
					var trElem = tdElem.closest('tr');
					var index = trElem.data('index');

					//计算总金额
					var amount = 0 ;//总金额
					if(t.c.sonlist!=null && t.c.sonlist.length>0){
						for(var i=0;i<t.c.sonlist.length;i++){
							if(t.c.sonlist[i].amount){
								amount = amount+parseFloat(t.c.sonlist[i].amount);
							}
						}
					}
					var domForm = $('#' + window.formObj.c.id_form);
					//回填总金额
					domForm.find('input[name="totalAmount"]').val(amount.toFixed(2));
				}
			});

		},

		listenFormItemByGridId81: function() {
			var t = this;
			// 初始化输入框
			$('input[data-filter="_input_filter_text_on_sub_grid"]').on('change',function (e) {
				var field = $(this).attr('name');
				if (field == 'stockNum') {//监听

					var tdElem = $(this).closest('td');
					var trElem = tdElem.closest('tr');
					var index = trElem.data('index');

					//计算
					var purchaseTotal = 0 ;//采购总量
					var purchaseTotalPrice = 0 ;//采购总价
					if(t.c.sonlist!=null && t.c.sonlist.length>0){
						for(var i=0;i<t.c.sonlist.length;i++){
							var stockNum = parseInt(t.c.sonlist[index]['stockNum']);
							var purchaseNum = parseInt(t.c.sonlist[index]['purchaseNum']);
							if (Number(stockNum) != 0) {
								//购买数量<=商品库存
								if (stockNum> purchaseNum ){
									layer.msg("购买数量不允许大于商品库存!");
									t.c.sonlist[index]['stockNum'] = 0;
									t.reloadGrid();
									return;
								}
							}
							if(t.c.sonlist[i].stockNum){
								purchaseTotal = purchaseTotal+parseFloat(t.c.sonlist[i].stockNum);
								purchaseTotalPrice = purchaseTotalPrice+(parseFloat(t.c.sonlist[i].stockNum) * parseFloat(t.c.sonlist[i].purchaseAmount));
							}
						}
					}
					var domForm = $('#' + window.formObj.c.id_form);
					//回填
					domForm.find('input[name="purchaseTotal"]').val(purchaseTotal);
					domForm.find('input[name="purchaseTotalPrice"]').val(purchaseTotalPrice.toFixed(2));
				}
			});

		},

		listenFormItemByGridId78: function() {
			var t = this;
			// 初始化输入框
			$('input[data-filter="_input_filter_text_on_sub_grid"]').on('change',function (e) {
				var field = $(this).attr('name');
				if (field == 'numPlanDeliver') {//监听

					var tdElem = $(this).closest('td');
					var trElem = tdElem.closest('tr');
					var index = trElem.data('index');
					var numStock = parseInt(t.c.sonlist[index]['numStock']);
					var numPlanDeliver = parseInt(t.c.sonlist[index]['numPlanDeliver']);
					if (Number(numPlanDeliver) != 0) {
						//计划发货数量<=库存可用数量
						if (numPlanDeliver > numStock ){
							layer.msg("计划发货数量不允许大于库存可用数量!");
							t.c.sonlist[index]['numPlanDeliver'] = 0;
							t.reloadGrid();
							return;
						}
					}
				}
			});

			// 初始化弹出框
			$('input[data-filter="_input_filter_modal_single_on_sub_grid"]').each(function(index, domEle){
				var modalKey = $(this).attr('data-modal-key');
				var colCode = $(this).attr('name');

				var tdElem = $(this).closest('td');
				var trElem = tdElem.closest('tr');
				var index = trElem.data('index');
				$(this).off('click');
				$(this).on('click',function (e) {
					var commodityCode = t.c.sonlist[index].commodityCode;
					if(commodityCode==undefined || commodityCode==null || commodityCode==''){
						layer.msg("商品编码不允许为空！", { icon: 2 });
						return;
					}

					var shopId = window.formObj.getValueByName("shopId");
					layui.YsModal.init({modalKey: modalKey, colCode: colCode, parentObj: t, extraData:{useIn: '_select_on_grid', index: index},
						sameCode: 'xx',pathGridRequest: '/api/inter/tpAmazonShopProduct/searchFbaPlan?code='+commodityCode+'&shopId='+shopId});

				});
			});

		},


		listenFormItemByGridId89: function() {
			var t = this;
			// 初始化输入框
			$('input[data-filter="_input_filter_text_on_sub_grid"]').on('change',function (e) {
				var field = $(this).attr('name');
				if (field == 'payAmount') {//监听

					var tdElem = $(this).closest('td');
					var trElem = tdElem.closest('tr');
					var index = trElem.data('index');
					//var payAmount = parseInt(t.c.sonlist[index]['payAmount']);
					//计算总金额
					var amount = 0 ;//总金额
					if(t.c.sonlist!=null && t.c.sonlist.length>0){
						for(var i=0;i<t.c.sonlist.length;i++){
							if(t.c.sonlist[i].payAmount){
								amount = amount+parseFloat(t.c.sonlist[i].payAmount);
							}
						}
					}
					var domForm = $('#' + window.formObj.c.id_form);
					//回填总金额
					domForm.find('input[name="totalAmount"]').val(amount.toFixed(2));



				}
			});


		},



		listenFormItemByGridId90: function() {
			var t = this;
			// 初始化输入框
			$('input[data-filter="_input_filter_text_on_sub_grid"]').on('change',function (e) {
				var field = $(this).attr('name');
				if (field == 'payAmount') {//监听

					var tdElem = $(this).closest('td');
					var trElem = tdElem.closest('tr');
					var index = trElem.data('index');
					//var payAmount = parseInt(t.c.sonlist[index]['payAmount']);
					//计算总金额
					var amount = 0 ;//总金额
					if(t.c.sonlist!=null && t.c.sonlist.length>0){
						for(var i=0;i<t.c.sonlist.length;i++){
							if(t.c.sonlist[i].payAmount){
								amount = amount+parseFloat(t.c.sonlist[i].payAmount);
							}
						}
					}
					var domForm = $('#' + window.formObj.c.id_form);
					//回填总金额
					domForm.find('input[name="totalAmount"]').val(amount.toFixed(2));



				}
			});


		},


		reloadGrid: function() {
        	var t = this;

			// 给数据添加序号
			t.addIndexToData();
			
			console.log('------reloadGrid-----', t.getData());

			layui.table.reload(t.c.id_table_sub, {
				data:t.getData()  //data为json数据
			});
			return;
		},
		addIndexToData: function() {
			for (var i = 0; i < this.c.sonlist.length; i++) {
				this.c.sonlist[i]['_ys_sub_grid_index'] = i;
			}
		},
		showModal: function(modalKey, colCode, index) {
			var t = this;

			// 打开单选框,
			layui.YsModal.init({modalKey: modalKey, colCode: colCode, parentObj: t, extraData:{useIn: '_select_on_grid', index: index}, conditionsDefault: [{code: 'aaa', value:'123'},{code: 'bbb', value:'456'}], sameCode: 'xx'});

		},
		matchValuesAfterModalSelectRadio:function (colCode, rowSelected, extraData) { // 单选框选中数据后，匹配表单数值
			var t = this;

			if (extraData.useIn == '_select_on_grid') {
				var index = extraData.index;

				for(var i = 0; i < t.c.colGridArr.length; i++){
					var col = t.c.colGridArr[i];
					if (col.field == colCode) {
						// 给选择框设置的字段赋值
						t.c.sonlist[index][col.field] = rowSelected[col.modalValueCode];
					} else if(col.modalRelativeCode == colCode) {
						// 给关联的字段赋值
						t.c.sonlist[index][col.field] = rowSelected[col.modalValueCode];
					}
				}

				t.reloadGrid();
				return;
			}

			// 处理单选
			if(t.c.gridId == 6) {
				t.getDataAfterRadio6(colCode, rowSelected, extraData);
			}else if(t.c.gridId == 14) {
				t.getDataAfterRadio14(colCode, rowSelected, extraData);
			} else if(t.c.gridId == 15) { // 预支台账明细
				t.getDataAfterRadio15(colCode, rowSelected, extraData);
			} else if(t.c.gridId == 17) { // 预支账户报销单列表
				t.getDataAfterRadio17(colCode, rowSelected, extraData);
			} else if(t.c.gridId == 29) { // 预付款退回申请
				t.getDataAfterRadio29(colCode, rowSelected, extraData);
				return;
			} else if(t.c.gridId == 72) { // 手工拆装单
				t.getDataAfterRadio72(colCode, rowSelected, extraData);
			}

			t.reloadGrid();
		},
		matchValuesAfterModalSelectCheckbox:function (rowsSelected, extraData) { // 复选框选中数据后，匹配表单数值
			var t = this;

			// 处理多选
			if(t.c.gridId == 3) { // 物料出库单明细
				t.getDataAfterCheckbox3(rowsSelected, extraData);
			} else if(t.c.gridId == 4) { // 员工工资申请表
				t.getDataAfterCheckbox4(rowsSelected, extraData);
			}  else if(t.c.gridId == 7) { // 物料借用单
				t.getDataAfterCheckbox7(rowsSelected, extraData);
			} else if(t.c.gridId == 8) { // 物料转移单明细
				t.getDataAfterCheckbox8(rowsSelected, extraData);
			} else if(t.c.gridId == 9) { // 员工月度绩效申报
				t.getDataAfterCheckbox9(rowsSelected, extraData);
			} else if(t.c.gridId == 10) { // 物料入库单详情
				t.getDataAfterCheckbox10(rowsSelected, extraData);
			} else if(t.c.gridId == 11) { // 医保付款单
				t.getDataAfterCheckbox11(rowsSelected, extraData);
			} else if(t.c.gridId == 12) { // 社保付款单
				t.getDataAfterCheckbox12(rowsSelected, extraData);
			} else if(t.c.gridId == 13) { // 公积金付款单
				t.getDataAfterCheckbox13(rowsSelected, extraData);
			}else if(t.c.gridId == 17) { // 预支账户报销单
				t.getDataAfterCheckbox17(rowsSelected, extraData);
			} else if(t.c.gridId == 19) { // 应付账户支付
				t.getDataAfterCheckbox19(rowsSelected, extraData);
			} else if(t.c.gridId == 20) { // 预约调拨详情
				t.getDataAfterCheckbox20(rowsSelected, extraData);
			} else if(t.c.gridId == 21) { // 资金登记单
				t.getDataAfterCheckbox21(rowsSelected, extraData);
			} else if(t.c.gridId == 23) { // 预付款认领单
				t.getDataAfterCheckbox23(rowsSelected, extraData);
			} else if(t.c.gridId == 24) { // 亚马逊店铺管理
				t.getDataAfterCheckbox24(rowsSelected, extraData);
			} else if(t.c.gridId == 25) { // 资金认领单
				t.getDataAfterCheckbox25(rowsSelected, extraData);
			} else if(t.c.gridId == 27) { // VAT申报
				t.getDataAfterCheckbox27(rowsSelected, extraData);
			} else if(t.c.gridId == 28) { // 万里汇提款单
				t.getDataAfterCheckbox28(rowsSelected, extraData);
			} else if(t.c.gridId == 30) { // 万里汇CNY付款单
				t.getDataAfterCheckbox30(rowsSelected, extraData);
			} else if(t.c.gridId == 31) { // 预付款退回申请列表
				t.getDataAfterCheckbox31(rowsSelected, extraData);
			} else if(t.c.gridId == 32) { // VAT申报详情
				t.getDataAfterCheckbox32(rowsSelected, extraData);
			} else if(t.c.gridId == 34) { // 万里汇预付款入账单
				t.getDataAfterCheckbox34(rowsSelected, extraData);
			} else if(t.c.gridId == 35) { // 万里汇外币付款单
				t.getDataAfterCheckbox35(rowsSelected, extraData);
			} else if(t.c.gridId == 36) { // 万里汇预付款对账单
				t.getDataAfterCheckbox36(rowsSelected, extraData);
			} else if(t.c.gridId == 33) { // 万里汇补账单
				t.getDataAfterCheckbox33(rowsSelected, extraData);
			} else if(t.c.gridId == 37) { // 财务工资小计部门维护表
				t.getDataAfterCheckbox37(rowsSelected, extraData);
			} else if(t.c.gridId == 38) { // 预约调拨取消单
				t.getDataAfterCheckbox38(rowsSelected, extraData);
			} else if(t.c.gridId == 39) { // 手工分配单
				t.getDataAfterCheckbox39(rowsSelected, extraData);
			} else if(t.c.gridId == 43) { // 财务交易类型子表
				t.getDataAfterCheckbox43(rowsSelected, extraData);
			} else if(t.c.gridId == 44) { // 费用结算返还单子表
				t.getDataAfterCheckbox44(rowsSelected, extraData);
			} else if(t.c.gridId == 47) { // 采购合同单子表
				t.getDataAfterCheckbox47(rowsSelected, extraData);
			} else if(t.c.gridId == 49) { // 采购预入库
				t.getDataAfterCheckbox49(rowsSelected, extraData);
			} else if(t.c.gridId == 51) { // 预约采购库
				t.getDataAfterCheckbox51(rowsSelected, extraData);
			} else if(t.c.gridId == 52) { // 发票预核销单
				t.getDataAfterCheckbox52(rowsSelected, extraData);
			}else if(t.c.gridId == 53) { // 采购付款单
				t.getDataAfterCheckbox53(rowsSelected, extraData);
			}else if(t.c.gridId == 58) { // 报关单
				t.getDataAfterCheckbox58(rowsSelected, extraData);
			}else if(t.c.gridId == 63) { // 采购计划单
				t.getDataAfterCheckbox63(rowsSelected, extraData);
			}else if(t.c.gridId == 71) { // 手工组装单
				t.getDataAfterCheckbox71(rowsSelected, extraData);
			}else if(t.c.gridId == 72) { // 手工拆装单
				t.getDataAfterCheckbox72(rowsSelected, extraData);
			}else if(t.c.gridId == 74) { // 库存调拨单
				t.getDataAfterCheckbox74(rowsSelected, extraData);
			}else if(t.c.gridId == 76) { // 库存出库
				t.getDataAfterCheckbox76(rowsSelected, extraData);
			}else if(t.c.gridId == 77) { // 库存入库
				t.getDataAfterCheckbox77(rowsSelected, extraData);
			}else if(t.c.gridId == 81) { // HW采购计划
				t.getDataAfterCheckbox81(rowsSelected, extraData);
			}else if(t.c.gridId == 78) { // FBA计划单
				t.getDataAfterCheckbox78(rowsSelected, extraData);
			}else if(t.c.gridId == 89) { // 物流付款单（关税费）
				t.getDataAfterCheckbox89(rowsSelected, extraData);
			}else if(t.c.gridId == 90) { // 物流付款单（物流费）
				t.getDataAfterCheckbox90(rowsSelected, extraData);
			}

			t.reloadGrid();
		},
		getDataAfterRadio6: function (colCode, rowSelected, extraData) {
			var t = this;
			$.ajax({
				async: false, // 同步获取
				type: "GET",
				url: '/api/inter/tbUserPayApply/searchGzXq',
				data: {pid:rowSelected.id},
				success: function (data) {
					if (data.code == 0) {
						t.c.sonlist = data.data
						if (data.data.length != 0){
							var  realityPaySlip = 0;
							for (let i = 0; i < data.data.length; i++) {
								realityPaySlip = realityPaySlip + Number(data.data[i].realityPaySlip)
							}
							t.c.formObj.setValueByName("userPayApplyBid",rowSelected.bid);
							t.c.formObj.setValueByName("orgName",rowSelected.orgName);
							t.c.formObj.setValueByName("userPayApplyid",rowSelected.id);
							t.c.formObj.setValueByName("realityPaySlip",realityPaySlip);
						}
					} else {
						alert(data.msg);
					}
				}
			});
		},

		getDataAfterRadio14: function (colCode, rowSelected, extraData) {
			var t = this;
			$.ajax({
				async: false, // 同步获取
				type: "GET",
				url: '/api/inter/tbUserPayApply/searchGsXq',
				data: {pid:rowSelected.id},
				success: function (data) {
					if (data.code == 0) {
						t.c.sonlist = data.data
						if (data.data.length != 0){
							var  retirementPersonal = 0;
							for (let i = 0; i < data.data.length; i++) {
								retirementPersonal = retirementPersonal + Number(data.data[i].retirementPersonal)
							}
							t.c.formObj.setValueByName("userPayApplyBid",rowSelected.bid);
							t.c.formObj.setValueByName("orgName",rowSelected.orgName);
							t.c.formObj.setValueByName("userPayApplyId",rowSelected.id);
							t.c.formObj.setValueByName("retirementPersonal",retirementPersonal);
						}
					} else {
						alert(data.msg);
					}
				}
			});
		},

		getDataAfterRadio15: function (colCode, rowSelected, extraData) {
			var t = this;
		},

		getDataAfterRadio17: function (colCode, rowSelected, extraData) {
			var t = this;
			t.c.sonlist.push({
				reimbursementItemId: null,
				advanceAccountDetailId: rowSelected.id,
				id:rowSelected.id,
				createTime:rowSelected.createTime,
				companyName:rowSelected.companyName,
				advanceTypeName:rowSelected.advanceTypeName,
				vjylx:rowSelected.vjylx,
				detailName:rowSelected.detailName,
				unitPrice:rowSelected.unitPrice,
				quantity:rowSelected.quantity,
				totalPrice:rowSelected.totalPrice,
				remark:rowSelected.remark,
				userName:rowSelected.userName,
				deptName:rowSelected.deptName,
				annexFile:rowSelected.annexFile,
				detailType:rowSelected.detailType,
				vgsbm:rowSelected.vgsbm,
				proxyPrice:rowSelected.proxyPrice,
				proxyTotalPrice:rowSelected.proxyTotalPrice,
			});
			//计算本次报销金额
			var totalPriceByThis = 0;
			if(t.c.sonlist!=null && t.c.sonlist.length>0){
				for(var i=0;i<t.c.sonlist.length;i++){
					var totalPriceByItem = parseFloat(t.c.sonlist[i].totalPrice);
					if(totalPriceByItem){
						totalPriceByThis = totalPriceByThis+totalPriceByItem;
					}
				}
			}
			window.formObj.setValueByName("totalPriceByThis",totalPriceByThis);
		},

		getDataAfterRadio29: function (colCode, rowSelected, extraData) {
			var t = this;
			var sonList = t.c.sonlist;
			if (colCode == 'vgsbm') {

				sonList = []
				var son = {
					vgsbm : rowSelected.vgsbm,
					vgsjc : rowSelected.vgsjc,
					vJyLx : "运营服务→预付款退回",
				}
				sonList.push(son);

				t.c.sonlist = sonList;

				var newOptions = [
					{name: "店铺回款", value: "0"},
					{name: "对公打款", value: "1"},
					{name: "空", value: "2"},
				];

				if (rowSelected.isDk == '是') {
					var paymentReturnType = 1;
				} else {
					var paymentReturnType = 0;
				}
				// 清空原有选项
				$('#paymentReturnType').empty();

				// 添加新的选项
				for (var i = 0; i < newOptions.length; i++) {
					if (i == Number(paymentReturnType)) {
						$('#paymentReturnType').append('<option selected value="' + newOptions[i].value + '">' + newOptions[i].name + '</option>');
					} else {
						$('#paymentReturnType').append('<option value="' + newOptions[i].value + '">' + newOptions[i].name + '</option>');
					}
				}

				// 更新select元素
				layui.form.render('select');

				var colNew = [];
				if (paymentReturnType == 1) {
                    for (let i = 0; i < t.c.colGridArr.length; i++) {
                        let coll = t.c.colGridArr[i];
                        if (coll.modalValueCode == 'vyhzhmc'){
                            coll.templet = null;
                        }
                        colNew.push(coll)
                    }
				} else {
					for (let i = 0; i < t.c.colGridArr.length; i++) {
                        let coll = t.c.colGridArr[i];
                        if (coll.modalValueCode == 'vyhzhmc'){
                            coll.templet ="#templet_script_sub_grid_13113";
                        }
                        if (coll.modalValueCode != 'tkVyhzh'
                            && coll.modalValueCode != 'tkVyhzhmc'
                            && coll.modalValueCode != 'tkVid'
                            && coll.modalValueCode != 'tkVkhh'
                            && coll.modalValueCode != 'refundableAmount'
                            && coll.modalValueCode != 'operateCompanyPrepaymentId'
                        ){
                            colNew.push(t.c.colGridArr[i])
                        }
					}
				}

				layui.table.reload(t.c.id_table_sub, {
					cols: [colNew]
					, data: t.getData()  //data为json数据
				});
			}else if (colCode == 'tkVyhzh') {
				sonList[0].tkVid = rowSelected.tkVid;
				sonList[0].tkVyhzh = rowSelected.tkVyhzh;
				sonList[0].tkVkhh = rowSelected.tkVkhh;
				sonList[0].tkVyhzhmc = rowSelected.tkVyhzhmc;
				sonList[0].refundableAmount = rowSelected.refundableAmount;
				sonList[0].operateCompanyPrepaymentId = rowSelected.operateCompanyPrepaymentId;
				sonList[0].operationsAttributeTxt = rowSelected.operationsAttributeTxt;
				sonList[0].vyhzhmc = rowSelected.fkVyhzhmc;
				sonList[0].vkhh = rowSelected.fkVkhh;
				sonList[0].vyhzh = rowSelected.fkVyhzh;
				sonList[0].vlhh = rowSelected.fkvlhh;
				sonList[0].companyBankId = rowSelected.companyBankInfoId,

				t.c.sonlist = sonList;

				layui.table.reload(t.c.id_table_sub, {
					 data: t.getData()  //data为json数据
				});
			}

		},


		getDataAfterRadio72: function (colCode, rowSelected, extraData) {
			var t = this;
			var sonList = t.c.sonlist;
			if(extraData!=null && extraData.length>0){
				for (var i = 0; i < extraData.length; i++) {
					for (var j = 0; j < sonList.length; j++) {
						if(sonList[j]._ys_sub_grid_index == extraData[i]._ys_sub_grid_index){
							sonList[i].subChw = rowSelected.chw;
							sonList[i].subVck = rowSelected.vck;
							sonList[i].subVkq = rowSelected.vkq;
							sonList[i].subVhw = rowSelected.vhw;
						}

					}
				}
				t.c.sonlist = sonList;
			}
		},



		getDataAfterCheckbox3: function (rowsSelected, extraData) {
			for (var i = 0; i < rowsSelected.length; i++) {
				var row = rowsSelected[i];
				this.c.sonlist.push({
					num: 0,
					remark: '',
					stockInImg: row.stockInImg,
					stockInPrice: row.stockInPrice,
					materialCode: row.materialCode,
					materialRemark: row.materialRemark,
					stockNum: row.num,
					stockId: row.id,
					bidStockIn: row.bidStockIn,
					createTime: row.createTime,
					stockRemark: row.remark,
					orgName: row.orgName,
					companyVname: row.companyVname,
					orgHeadUserId: row.orgHeadUserId,
					stockDays: row.stockDays
				});
			}

		},
		getDataAfterCheckbox4: function (rowsSelected, extraData) {
			if(this.c.sonlist != 0){
				let newall=[]
				let endData = [];
				var isdata=false
				for (let i = 0; i < rowsSelected.length; i++) {
					var isdata=false
					if (newall.indexOf(rowsSelected[i].userPaySlipidid) === -1) {
						for (let n = 0; n < this.c.sonlist.length; n++) {
							if (newall.indexOf(rowsSelected[i].userPaySlipidid) === -1) {
								if(rowsSelected[i].userPaySlipidid==this.c.sonlist[n].userPaySlipidid){
									isdata=true
									endData.push(this.c.sonlist[n]);
									newall.push(this.c.sonlist[n].userPaySlipidid);
								}
							}
						}
						if(!isdata){
							endData.push(rowsSelected[i]);
							newall.push(rowsSelected[i].userPaySlipidid);
						}
					}
				}
				this.c.sonlist = endData
			}else{
				this.c.sonlist = rowsSelected
			}
			//计算逻辑
			var wagesPay = 0;
			var healthCompany = 0;
			var societyCompany = 0;
			var needPaySlip = 0;
			var personalTax = 0;
			var realityPaySlip = 0;
			var accumulationFundCompany = 0;
			for (let n = 0; n < this.c.sonlist.length; n++) {
				wagesPay = wagesPay + Number(this.c.sonlist[n].wagesPay)
				healthCompany = healthCompany + Number(this.c.sonlist[n].healthCompany)
				societyCompany = societyCompany + Number(this.c.sonlist[n].retirementCompany)+ Number(this.c.sonlist[n].loseWorkCompany)+ Number(this.c.sonlist[n].injuryCompany)
				needPaySlip = needPaySlip + Number(this.c.sonlist[n].needPaySlip)
				personalTax = personalTax + Number(this.c.sonlist[n].personalTax)
				realityPaySlip = realityPaySlip + Number(this.c.sonlist[n].realityPaySlip)
				accumulationFundCompany = accumulationFundCompany + Number(this.c.sonlist[n].accumulationFundCompany)
			}
			if (this.c.sonlist.length != 0){
				this.c.formObj.setValueByName("orgName",this.c.sonlist[0].orgName);
				this.c.formObj.setValueByName("wagesPay",this.toFixed(wagesPay,2));
				this.c.formObj.setValueByName("healthCompany",this.toFixed(healthCompany,2));
				this.c.formObj.setValueByName("societyCompany",this.toFixed(societyCompany,2));
				this.c.formObj.setValueByName("needPaySlip",this.toFixed(needPaySlip,2));
				this.c.formObj.setValueByName("personalTax",this.toFixed(personalTax,2));
				this.c.formObj.setValueByName("realityPaySlip",this.toFixed(realityPaySlip,2));
				this.c.formObj.setValueByName("accumulationFundCompany",this.toFixed(accumulationFundCompany,2));
				this.c.formObj.setValueByName("orgId",this.c.sonlist[0].orgId);
				this.c.formObj.setValueByName("pointMonth",this.c.sonlist[0].pointMonth);
			}
		},
		getDataAfterCheckbox7: function (rowsSelected, extraData) {
			for (var i = 0; i < rowsSelected.length; i++) {
				var row = rowsSelected[i];
				this.c.sonlist.push({
					stockId: row.id,
					remark: '',
					mg: row.img,
					materialCode: row.materialCode,
					materialName: row.materialName,
					materialRemark: row.materialRemark,
					stockNum: row.numAll,
					stockRemark: row.stockRemark,
					num: '',
					price: row.price,
					bidStockIn: row.bidStockIn,
					companyVname: row.companyVname,
					stockInDay: row.stockInDay,
					stockInDays: row.stockInDays,
					numBorrowed: row.numBorrowed
				});
			}


			return;
			if (this.c.sonlist.length != 0){
				this.c.formObj.setValueByName("numBorrowed",this.c.sonlist[0].numBorrowed);
				this.c.formObj.setValueByName("orgHeadUserId",this.toFixed(orgHeadUserId,2));
				this.c.formObj.setValueByName("orgName",this.toFixed(orgName,2));
				this.c.formObj.setValueByName("companyVname",this.toFixed(companyVname,2));
				this.c.formObj.setValueByName("storageDay",this.toFixed(storageDay,2));
				this.c.formObj.setValueByName("storageTime",this.toFixed(storageTime,2));
				this.c.formObj.setValueByName("bidStockIn",this.toFixed(bidStockIn,2));
				this.c.formObj.setValueByName("price",this.toFixed(price,2));
				this.c.formObj.setValueByName("quantityBorrowed",this.toFixed(quantityBorrowed,2));
				this.c.formObj.setValueByName("inventoryQuantity",this.c.sonlist[0].inventoryQuantity);
				this.c.formObj.setValueByName("materialRemark",this.toFixed(materialRemark,2));
				this.c.formObj.setValueByName("materialName",this.toFixed(materialName,2));
				this.c.formObj.setValueByName("materialCode",this.toFixed(materialCode,2));
				this.c.formObj.setValueByName("img",this.toFixed(img,2));
				this.c.formObj.setValueByName("remarks",this.toFixed(remarks,2));
			}
		},
		getDataAfterCheckbox8: function (rowsSelected, extraData) {
			for (var i = 0; i < rowsSelected.length; i++) {
				var row = rowsSelected[i];
				this.c.sonlist.push({
					num: 0,
					remark: '',
					stockId: row.id,
					numStock: row.num,
					numBorrowed: row.numBorrowed,
					orgHeadUserId: row.orgHeadUserId,
					orgName: row.orgName,
					companyVname: row.companyVname,
					storageDay: row.storageDay,
					storageTime: row.storageTime,
					bidStockIn: row.bidStockIn,
					price: row.price,
					quantityBorrowed: row.quantityBorrowed,
					inventoryQuantity: row.inventoryQuantity,
					materialRemark: row.materialRemark,
					materialName: row.materialName,
					materialCode: row.materialCode,
					img: row.stockInImg,
					remarks: '',
					borrowingDepartment: row.borrowingDepartment,
					borrowers: row.borrowers
				});
			}
		},
		getDataAfterCheckbox9: function (rowsSelected, extraData) {//员工月度绩效申报
			var t = this;
			//var rowCurrents = [];
			for (var i = 0; i < rowsSelected.length; i++) {
				var obj = rowsSelected[i];
				var rowCurrent = {};
				rowCurrent.id = null;
				rowCurrent.monthPerformanceId = obj.id;

				rowCurrent.pointMonth = obj.pointMonth;//评定年月
				rowCurrent.userName = obj.userName;//工号/姓名
				rowCurrent.userState = obj.userState;//员工状态
				rowCurrent.deptName = obj.deptName;//部门
				rowCurrent.orgName = obj.orgName;//所属公司
				rowCurrent.rank = obj.rank;//岗位职级
				rowCurrent.type = obj.type;//岗位工种

				rowCurrent.hrPerformancePoint = 0.00;//人事绩效评分
				rowCurrent.hrPerformanceContent = '';//人事绩效内容
				rowCurrent.jobBonus = obj.jobBonus?obj.jobBonus:0.00;//岗位提奖
				rowCurrent.jobBonusExplain = obj.jobBonusExplain?obj.jobBonusExplain:'';//岗位提奖说明
				//过滤已选择的
				if(t.c.sonlist!=null && t.c.sonlist.length>0){
					var isChoosed = false;
					for (var j = 0; j < t.c.sonlist.length; j++) {
						if(t.c.sonlist[j].monthPerformanceId == obj.id){
							isChoosed = true;
						}
					}
				}
				if(!isChoosed){
					t.c.sonlist.push(rowCurrent);
					//t.addRow(rowCurrent);
				}
			}
		},
		getDataAfterCheckbox10: function (rowsSelected, extraData) {
			for (var i = 0; i < rowsSelected.length; i++) {
				var row = rowsSelected[i];
				this.c.sonlist.push({
					num: '',
					price: '',
					materialCode: row.code,
					materialName: row.name,
					materialRemark: row.remark,
					remark: ''
				});
			}
		},
		getDataAfterCheckbox11: function (rowsSelected, extraData) {
			var t = this;
			if(this.c.sonlist != 0){
				let newall=[]
				let endData = [];
				var isdata=false
				for (let i = 0; i < rowsSelected.length; i++) {
					var isdata=false
					if (newall.indexOf(rowsSelected[i].userMonthPerformanceId) === -1) {
						for (let n = 0; n < this.c.sonlist.length; n++) {
							if (newall.indexOf(rowsSelected[i].userMonthPerformanceId) === -1) {
								if(rowsSelected[i].userMonthPerformanceId==this.c.sonlist[n].userMonthPerformanceId){
									isdata=true
									endData.push(this.c.sonlist[n]);
									newall.push(this.c.sonlist[n].userMonthPerformanceId);
								}
							}
						}
						if(!isdata){
							endData.push(rowsSelected[i]);
							newall.push(rowsSelected[i].userMonthPerformanceId);
						}
					}
				}
				this.c.sonlist = endData
			}else{
				this.c.sonlist = rowsSelected
			}
			//计算逻辑
			var healthCompany = 0;
			var healthPersonal = 0;
			var birthCompany = 0;
			var orgName = "";
			for (let n = 0; n < this.c.sonlist.length; n++) {
				orgName = this.c.sonlist[n].orgName
				healthCompany = healthCompany + Number(this.c.sonlist[n].healthCompany)
				healthPersonal = healthPersonal + Number(this.c.sonlist[n].healthPersonal)
				birthCompany = birthCompany + Number(this.c.sonlist[n].birthCompany)
			}
			if (this.c.sonlist.length != 0){
				t.c.formObj.setValueByName("orgName",orgName);
				t.c.formObj.setValueByName("healthCompany",healthCompany);
				t.c.formObj.setValueByName("healthPersonal",healthPersonal);
				t.c.formObj.setValueByName("healthTol",healthCompany+healthPersonal);
			}
		},
		getDataAfterCheckbox12: function (rowsSelected, extraData) {
			var t = this;
			if(this.c.sonlist != 0){
				let newall=[]
				let endData = [];
				var isdata=false
				for (let i = 0; i < rowsSelected.length; i++) {
					var isdata=false
					if (newall.indexOf(rowsSelected[i].userMonthPerformanceId) === -1) {
						for (let n = 0; n < this.c.sonlist.length; n++) {
							if (newall.indexOf(rowsSelected[i].userMonthPerformanceId) === -1) {
								if(rowsSelected[i].userMonthPerformanceId==this.c.sonlist[n].userMonthPerformanceId){
									isdata=true
									endData.push(this.c.sonlist[n]);
									newall.push(this.c.sonlist[n].userMonthPerformanceId);
								}
							}
						}
						if(!isdata){
							endData.push(rowsSelected[i]);
							newall.push(rowsSelected[i].userMonthPerformanceId);
						}
					}
				}
				this.c.sonlist = endData
			}else{
				this.c.sonlist = rowsSelected
			}
			//计算逻辑
			var societyCompany = 0;
			var societyPersonal = 0;
			var orgName = "";
			for (let n = 0; n < this.c.sonlist.length; n++) {
				orgName = this.c.sonlist[n].orgName
				societyCompany = societyCompany + Number(this.c.sonlist[n].retirementCompany)+ Number(this.c.sonlist[n].loseWorkCompany)+ Number(this.c.sonlist[n].injuryCompany)
				societyPersonal = societyPersonal + Number(this.c.sonlist[n].retirementPersonal)+ Number(this.c.sonlist[n].loseWorkPersonal)
			}
			if (this.c.sonlist.length != 0){
				t.c.formObj.setValueByName("orgName",orgName);
				t.c.formObj.setValueByName("societyCompany",societyCompany);
				t.c.formObj.setValueByName("societyPersonal",societyPersonal);
				t.c.formObj.setValueByName("societyTol",societyCompany+societyPersonal);
			}
		},
		getDataAfterCheckbox13: function (rowsSelected, extraData) {
			var t = this;
			if(this.c.sonlist != 0){
				let newall=[]
				let endData = [];
				var isdata=false
				for (let i = 0; i < rowsSelected.length; i++) {
					var isdata=false
					if (newall.indexOf(rowsSelected[i].userMonthPerformanceId) === -1) {
						for (let n = 0; n < this.c.sonlist.length; n++) {
							if (newall.indexOf(rowsSelected[i].userMonthPerformanceId) === -1) {
								if(rowsSelected[i].userMonthPerformanceId==this.c.sonlist[n].userMonthPerformanceId){
									isdata=true
									endData.push(this.c.sonlist[n]);
									newall.push(this.c.sonlist[n].userMonthPerformanceId);
								}
							}
						}
						if(!isdata){
							endData.push(rowsSelected[i]);
							newall.push(rowsSelected[i].userMonthPerformanceId);
						}
					}
				}
				this.c.sonlist = endData
			}else{
				this.c.sonlist = rowsSelected
			}
			//计算逻辑
			var accumulationFundCompany = 0;
			var accumulationFundPersonal = 0;
			var orgName = "";
			for (let n = 0; n < this.c.sonlist.length; n++) {
				orgName = this.c.sonlist[n].orgName
				accumulationFundCompany = accumulationFundCompany + Number(this.c.sonlist[n].accumulationFundCompany)
				accumulationFundPersonal = accumulationFundPersonal + Number(this.c.sonlist[n].accumulationFundPersonal)
			}
			if (this.c.sonlist.length != 0){
				t.c.formObj.setValueByName("orgName",orgName);
				t.c.formObj.setValueByName("accumulationFundCompany",accumulationFundCompany);
				t.c.formObj.setValueByName("accumulationFundPersonal",accumulationFundPersonal);
				t.c.formObj.setValueByName("accumulationTol",accumulationFundCompany+accumulationFundPersonal);
			}
		},
		getDataAfterCheckbox17: function (rowsSelected, extraData) {
			var t=this;
			for (var i = 0; i < rowsSelected.length; i++) {
				var row = rowsSelected[i];
				var isAdd = true; // 根据现有存在，是否加新行
				for (var j = 0; j < t.c.sonlist.length; j++) {
					if (t.c.sonlist[j].advanceAccountDetailId == row.id) {
						isAdd = false;
					}
				}
				if(isAdd){
					this.c.sonlist.push({
						reimbursementItemId: null,
						advanceAccountDetailId: row.id,
						id:row.id,
						createTime:row.createTime,
						companyName:row.companyName,
						advanceTypeName:row.advanceTypeName,
						vjylx:row.vjylx,
						detailName:row.detailName,
						unitPrice:row.unitPrice,
						quantity:row.quantity,
						totalPrice:row.totalPrice,
						remark:row.remark,
						userName:row.userName,
						deptName:row.deptName,
						annexFile:row.annexFile,
						detailType:row.detailType,
						vgsbm:row.vgsbm,
						proxyPrice:row.proxyPrice,
						proxyTotalPrice:row.proxyTotalPrice,
					});
				}
			}
			var totalPriceByThis = 0;
			if(t.c.sonlist!=null && t.c.sonlist.length>0){
				for(var i=0;i<t.c.sonlist.length;i++){
					var totalPriceByItem = parseFloat(t.c.sonlist[i].totalPrice);
					if(totalPriceByItem){
						totalPriceByThis = totalPriceByThis+totalPriceByItem;
					}
				}
			}
			window.formObj.setValueByName("totalPriceByThis",totalPriceByThis);
		},
		getDataAfterCheckbox19: function (rowsSelected, extraData) {
			var t=this;
			for (var i = 0; i < rowsSelected.length; i++) {
				var row = rowsSelected[i];
				var isAdd = true; // 根据现有存在，是否加新行
				for (var j = 0; j < t.c.sonlist.length; j++) {
					if (t.c.sonlist[j].needPayLedgerDetailId == row.id) {
						isAdd = false;
					}
				}
				if(isAdd){
					this.c.sonlist.push({
						needPayLedgerDetailId: row.id,
						createTime: row.createTime,
						needPayTypeCode: row.needPayTypeCode,
						needPayTypeName: row.needPayTypeName,
						vgsbm: row.vgsbm,
						vgsjc: row.vgsjc,
						vjylx: row.vjylx,
						detailName: row.detailName,
						costPrice: row.costPrice,
						quantity: row.quantity,
						totalPrice: row.totalPrice,
						materialRemark: row.remark,
						servicePrice: row.servicePrice,
						payedPrice: row.payedPrice,
						proxyPrice: row.proxyPrice,
						//unpayPrice: (row.costPrice * row.quantity - row.payedPrice),
						unpayPrice:0,
						amount: (row.costPrice * row.quantity).toFixed(2)
					});
				}

			}
		},
		getDataAfterCheckbox20: function (rowsSelected, extraData) {
			var t = this;
        	var rows = [];
        	for (var i = 0; i < rowsSelected.length; i++) {
				var rowSelected = rowsSelected[i];

				var isAdd = true; // 根据现有存在，是否加新行
				for (var j = 0; j < this.c.sonlist.length; j++) {
					if (this.c.sonlist[j].productCode == rowSelected.code) {
						isAdd = false;
					}
				}

				var type = t.c.formObj.getValueByName("type");

				if (isAdd == true) {
					var row = {
						productCode: rowSelected.code,
						productName: rowSelected.name,
						singlePrice: rowSelected.priceIn,
						vgsbmFrom: type == 1 ? 'GS0641' : 'GS0877',
						vgsjcFrom: type == 1 ? '逸思精品' : '逸思库存'
					};
					this.c.sonlist.push(row);
				}
			}
		},
		getDataAfterCheckbox21: function (rowsSelected, extraData) {
			var t = this;

			for (var i = 0; i < rowsSelected.length; i++) {
				var row = rowsSelected[i];
				var isAdd = true; // 根据现有存在，是否加新行
				for (var j = 0; j < t.c.sonlist.length; j++) {

					if (t.c.sonlist[j].vid == row.vid) {
						isAdd = false;
					}
				}
				if (isAdd == true) {
					var addRow = {
						id:'',
						paymentTime: '',
						operateCompanyBankInfoId : row.id,
						vid: row.vid,
						vyhzhmc: row.vyhzhmc,
						vkhh: row.vkhh,
						vyhzh: row.vyhzh,
						paymentAmount:0.00,
						accountType: row.accountType,
						accountTypeTxt: row.accountType!=null &&row.accountType==0?'对公户':'个人户',
						vjylx:'运营服务→预付款'
					};
					if(row.accountType==0){//对公户
						addRow.claimVgsmc = row.vyhzhmc;
					}
					t.c.sonlist.push(addRow);
				}

			}
		},

		getDataAfterCheckbox23: function (rowsSelected, extraData) {
			var t = this;

			for (var i = 0; i < rowsSelected.length; i++) {
				var row = rowsSelected[i];
				var isAdd = true; // 根据现有存在，是否加新行
				for (var j = 0; j < t.c.sonlist.length; j++) {
					if (t.c.sonlist[j].vid == row.vid) {
						isAdd = false;
					}
				}
				if (isAdd) {
					t.c.sonlist.push({
						id:'',
						paymentTime: '',
						operateCompanyBankInfoId: row.id,
						vid : row.vid,
						vyhzhmc: row.vyhzhmc,
						vkhh: row.vkhh,
						vyhzh: row.vyhzh,
						paymentAmount:'',
						capitalRegisterBid:'',
						paymentVyhzhmc:'',
						paymentVkhh:'',
						paymentVyhzh:'',
						paymentTimeByClaim:'',
						paymentAmountByClaim:'',
						vjylx:'运营服务→预付款',
						accountingVgsbm:'',
						accountingVgsmc:'',
						annexFile:'0个附件',
						remark:'',
					});
				}
			}
		},
		getDataAfterCheckbox24: function (rowsSelected, extraData) {
			var t = this;

			for (var i = 0; i < rowsSelected.length; i++) {
				var row = rowsSelected[i];
				var isAdd = true; // 根据现有存在，是否加新行
				for (var j = 0; j < t.c.sonlist.length; j++) {

					if (t.c.sonlist[j].siteId == row.id) {
						isAdd = false;
					}
				}
				if (isAdd == true) {
					t.c.sonlist.push({
						siteId: row.id,
						shopUser:'',
						shopName: '',
						countryCode : row.countryCode,
						countryName: row.countryName,
						status: 1,
						euStatus: 0
					});
				}

			}
		},

		getDataAfterCheckbox25: function (rowsSelected, extraData) {
			var t = this;

			for (var i = 0; i < rowsSelected.length; i++) {
				var row = rowsSelected[i];
				var isAdd = true; // 根据现有存在，是否加新行
				for (var j = 0; j < t.c.sonlist.length; j++) {
					if (t.c.sonlist[j].vid == row.vid) {
						isAdd = false;
					}
				}
				if (isAdd) {
					t.c.sonlist.push({
						id:'',
						paymentTime: '',
						operateCompanyBankInfoId: row.id,
						vid : row.vid,
						vyhzhmc: row.vyhzhmc,
						vkhh: row.vkhh,
						vyhzh: row.vyhzh,
						paymentAmount:'',
						capitalRegisterBid:'',
						paymentVyhzhmc:'',
						paymentVkhh:'',
						paymentVyhzh:'',
						paymentTimeByClaim:'',
						paymentAmountByClaim:'',
						vjylx:'运营服务→预付款',
						accountingVgsbm:'',
						accountingVgsmc:'',
						annexFile:'0个附件',
						remark:'',
					});
				}
			}
		},
		getDataAfterCheckbox27: function (rowsSelected, extraData) {
			var t = this;

			for (var i = 0; i < rowsSelected.length; i++) {
				var row = rowsSelected[i];
				var isAdd = true; // 根据现有存在，是否加新行
				for (var j = 0; j < t.c.sonlist.length; j++) {

					if (t.c.sonlist[j].vatNo == row.vatNo) {
						isAdd = false;
					}
				}
				if (isAdd == true) {
					$.ajax({
						async: false, // 同步获取
						type: "GET",
						url: '/api/inter/thrVatApply/getLastApply',
						data: {vatNo: row.vatNo},
						success: function (res) {
							var lastDateBegin = '';
							var lastDateEnd = '';
							if (res.code == 0) {
								lastDateBegin = res.data.lastDateBegin;
								lastDateEnd = res.data.lastDateEnd;
							}
							t.c.sonlist.push({
								vgsbm: row.vgsbm,
								vgsjc: row.vgsjc,
								type: 1,
								vatNo: row.vatNo,
								countryCode: row.countryCode,
								countryName: row.countryName,
								lastDateBegin: lastDateBegin,
								lastDateEnd: lastDateEnd,
								currencyCode: row.currencyCode
							});
						}
					});
				}

			}
		},

		getDataAfterCheckbox28: function (rowsSelected, extraData) {
			var t = this;

			for (var i = 0; i < rowsSelected.length; i++) {
				var row = rowsSelected[i];
				var isAdd = true; // 根据现有存在，是否加新行
				for (var j = 0; j < t.c.sonlist.length; j++) {
					if (t.c.sonlist[j].vid == row.vid) {
						isAdd = false;
					}
				}
				if (isAdd) {
					t.c.sonlist.push({
						id:'',
						paymentTime: '',
						companyBankInfoId: row.id,
						vid : row.vid,
						vyhzhmc: row.vyhzhmc,
						vkhh: row.vkhh,
						vyhzh: row.vyhzh,
						inCurrencyCode:'CNY',
						outCurrencyCode:'',
						outSum:'',
						inSum:''
					});
				}
			}
		},

		getDataAfterCheckbox30: function (rowsSelected, extraData) {
			var t = this;

			for (var i = 0; i < rowsSelected.length; i++) {
				var row = rowsSelected[i];
				var isAdd = true; // 根据现有存在，是否加新行
				for (var j = 0; j < t.c.sonlist.length; j++) {
					if (t.c.sonlist[j].vid == row.vid) {
						isAdd = false;
					}
				}
				if (isAdd) {
					t.c.sonlist.push({
						partnerBankInfoVid: row.vid,
						partnerBankInfoVyhzhmc: row.vyhzhmc,
						partnerBankInfoVyhzh: row.vyhzh,
						partnerBankInfoVkhh: row.vkhh,
						currencyCodeOut: 'USD',
						currencyCodeIn: 'CNY'
					});
				}
			}
		},

		getDataAfterCheckbox31: function (rowsSelected, extraData) {

			var t = this;

			for (var i = 0; i < rowsSelected.length; i++) {
				var row = rowsSelected[i];
				var isAdd = true; // 根据现有存在，是否加新行
				for (var j = 0; j < t.c.sonlist.length; j++) {
					if (t.c.sonlist[j].paymentReturnItemId == row.paymentReturnItemId) {
						isAdd = false;
					}
				}
				if (isAdd) {
					t.c.sonlist.push({
						paymentReturnBid: row.bid,
						vgsbm:row.vgsbm,
						vgsjc:row.vgsjc,
						depositPlatformAccountCode:row.depositPlatformAccountCode,
						vJyLx:row.vJyLx,
						statePay:0,
						accountType:row.accountType,
						vyhzh:row.vyhzh,
						vyhzhmc:row.vyhzhmc,
						zfAmount:row.zfAmount,
						exchangeRate:row.exchangeRate,
						serviceCharge:row.serviceCharge,
						thCurrencyCode:row.thCurrencyCode,
						thAmount:row.thAmount,
						paymentReturnItemId:row.paymentReturnItemId,
						vkhh:row.vkhh,
						vlhh:row.vlhh,
					});
				}
			}
		},

		getDataAfterCheckbox32: function (rowsSelected, extraData) {
			var t = this;
			for (var i = 0; i < rowsSelected.length; i++) {
				var row = rowsSelected[i];
				var isAdd = true; // 根据现有存在，是否加新行
				for (var j = 0; j < t.c.sonlist.length; j++) {
					if (t.c.sonlist[j].id == row.id) {
						isAdd = false;
					}
				}
				if (isAdd) {
					t.c.sonlist.push({
						logInvoiceNo: row.logInvoiceNo,
						declareStateName: row.declareStateName,
						declareTime: row.declareTime,
						fbaNo: row.fbaNo,
						country: row.country,
						annexFile: row.annexFile,
						cbbId: row.id,
						vgsbm: row.vgsbm,
						vgsjc: row.vgsjc
					});
				}
			}
		},
		getDataAfterCheckbox33: function (rowsSelected, extraData) {
			for (var i = 0; i < rowsSelected.length; i++) {
				var row = rowsSelected[i];
				this.c.sonlist.push({
					id: '',
					platformName: row.platformName,
					depositPlatformCode: row.code,
					name: row.name,
					vname: row.vname,
					remark: row.remark,
					explain: '',
					currencyCode: '',
					amount: ''
				});
			}


			return;
			if (this.c.sonlist.length != 0){
				// this.c.formObj.setValueByName("numBorrowed",this.c.sonlist[0].numBorrowed);
				this.c.formObj.setValueByName("platformName",this.toFixed(platformName,2));
				this.c.formObj.setValueByName("code",this.toFixed(code,2));
				this.c.formObj.setValueByName("name",this.toFixed(name,2));
				this.c.formObj.setValueByName("vname",this.toFixed(vname,2));
				this.c.formObj.setValueByName("pbid",this.toFixed(pbid,2));
			}
		},
		getDataAfterCheckbox34: function (rowsSelected, extraData) {//万里汇预付款入账单
			var domForm = $('#' + window.formObj.c.id_form);
			for (var i = 0; i < rowsSelected.length; i++) {
				var row = rowsSelected[i];
				row.itemId = "";
				row.reconciliationItemId = row.id;
				var exchangeRate = 0;
				var recordAmountGuiji = parseFloat(row.recordAmountGuiji);//记录归集金额
				var jyCurrencyCode = row.jyCurrencyCode;//币种
				if(jyCurrencyCode=="GBP"){
					exchangeRate = parseFloat(domForm.find('input[name="exchangeRateByGbp"]').val());
				}else if(jyCurrencyCode=="USD"){
					exchangeRate = parseFloat(domForm.find('input[name="exchangeRateByUsd"]').val());
				}else if(jyCurrencyCode=="EUR"){
					exchangeRate = parseFloat(domForm.find('input[name="exchangeRateByEur"]').val());
				}
				//计算入账金额（CNY） = 记录归集金额*对应币种的计算汇率*0.998*0.98
				var recordedAmount = recordAmountGuiji*exchangeRate*0.998*0.98;
				row.recordedAmount = recordedAmount.toFixed(2);
				this.c.sonlist.push(row);
			}
			var recordedTotal = parseFloat(domForm.find('input[name="recordedTotal"]').val());//总入账金额（CNY）
			var recordedOperations = 0;//运营入账金额（CNY） = 子表入账金额之和
			for(var i=0;i<this.c.sonlist.length; i++){
				var recordedAmountByItem = parseFloat(this.c.sonlist[i].recordedAmount);
				recordedOperations = recordedOperations+recordedAmountByItem;
			}
			var recordedFinance = recordedTotal - recordedOperations;//财务入账金额（CNY） = 总入账金额（CNY）-运营入账金额（CNY）
			domForm.find('input[name="recordedOperations"]').val(recordedOperations.toFixed(2));
			domForm.find('input[name="recordedFinance"]').val(recordedFinance.toFixed(2));
		},

		getDataAfterCheckbox35: function (rowsSelected, extraData) {
			var t = this;
		    var domForm = $('#' + window.formObj.c.id_form);
			var payType = domForm.find('select[name="payType"]').val(); // 付款类型
			var exchangeRate = parseFloat(domForm.find('input[name="exchangeRate"]').val()); // 计算汇率

			for (var i = 0; i < rowsSelected.length; i++) {
				var row = rowsSelected[i];
				var isAdd = true; // 根据现有存在，是否加新行
				for (var j = 0; j < t.c.sonlist.length; j++) {
					if (t.c.sonlist[j].relativeId == row.id) {
						isAdd = false;
					}
				}
				if (isAdd) {
					var fee = 0;
					var remark = '';
					if (payType == 1) {
						remark = (row.platformBid ? row.platformBid : '');
					} else if (payType == 2) {
						remark =  (row.vatNo ? row.vatNo : '');
					}
					
					t.c.sonlist.push({
						relativeId: row.id,
						vgsbm: row.vgsbm,
						vgsjc: row.vgsjc,
						vyhzhmc: row.vyhzhmc,
						vyhzh: row.vyhzh,
						vkhh: row.vkhh,
						vaba: row.vaba,
						swiftCode: row.swiftCode,
						amount: row.billingAmount,
						currencyCode: row.currencyCode,
						remark: remark,
						vjylx: payType == 1 ? '运营服务→透明计划标签费用' : (payType == 2 ? '运营服务→VAT税费' : ''),
						fee: fee,
						amountCny: exchangeRate ? Math.round((row.billingAmount + fee) * exchangeRate * 100) / 100 : 0
					});
				}
			}
			// 计算付款外币总金额、付款CNY总金额
			if(exchangeRate) {
				var amountTotalLocal = 0;
				var amountTotalCny = 0;
				for (var i = 0; i < t.c.sonlist.length; i++) {
					var amount = parseFloat(t.c.sonlist[i]['amount']);
					if(amount) {
						amountTotalLocal = amountTotalLocal + amount;
						amountTotalCny = amountTotalCny + Math.round(amount * exchangeRate * 100) / 100;
					}
				}
				domForm.find('input[name="amountTotalLocal"]').val(amountTotalLocal);
				domForm.find('input[name="amountTotalCny"]').val(Math.round(amountTotalCny * 100) / 100);
			}
		},

		getDataAfterCheckbox36: function (rowsSelected, extraData) {
			var t = this;

			for (var i = 0; i < rowsSelected.length; i++) {
				var row = rowsSelected[i];
				var isAdd = true; // 根据现有存在，是否加新行
				for (var j = 0; j < t.c.sonlist.length; j++) {
					if (t.c.sonlist[j].wanliPrepaymentPoolingId == row.id) {
						isAdd = false;
					}
				}
				if (isAdd) {
					t.c.sonlist.push({
						wanliPrepaymentPoolingId: row.id,
						fkMid: row.fkMid,
						payerAccountNo: row.payerAccountNo,
						payerName: row.payerName,
						fkVyhsx: row.fkVyhsx,
						skMid: row.skMid,
						beneficiaryAccountNo: row.beneficiaryAccountNo,
						beneficiaryName: row.beneficiaryName,
						skVyhsx: row.skVyhsx,
						transactionType: row.transactionType,
						originalTransactionAmount: row.originalTransactionAmount,
						jyCurrencyCode: row.jyCurrencyCode,
						extTransactionId: row.extTransactionId,
						transactionId: row.transactionId,
						transactionTime: row.transactionTime,
						transactionStatus: row.transactionStatus,
						description: row.description,
						vgsbm: row.vgsbm,
						vgsjc: row.vgsjc,
						recordAmountGuiji: row.originalTransactionAmount
					});
				}
			}
			
			// 根据币种计算归集总金额
			var amountGuijiGbp = 0;
			var amountGuijiUsd = 0;
			var amountGuijiEur = 0;
			for (var i = 0; i < t.c.sonlist.length; i++) {
				var jyCurrencyCode = t.c.sonlist[i].jyCurrencyCode;
				var recordAmountGuiji = t.c.sonlist[i].recordAmountGuiji
				if(jyCurrencyCode == 'GBP') {
					amountGuijiGbp = amountGuijiGbp + recordAmountGuiji;
				} else if(jyCurrencyCode == 'USD') {
					amountGuijiUsd = amountGuijiUsd + recordAmountGuiji;
				} else if(jyCurrencyCode == 'EUR') {
					amountGuijiEur = amountGuijiEur + recordAmountGuiji;
				}
			}
		    var domForm = $('#' + window.formObj.c.id_form);
			domForm.find('input[name="amountGuijiGbp"]').val(amountGuijiGbp);
			domForm.find('input[name="amountGuijiUsd"]').val(amountGuijiUsd);
			domForm.find('input[name="amountGuijiEur"]').val(amountGuijiEur);
		},

		getDataAfterCheckbox37: function (rowsSelected, extraData) {//财务工资小计部门维护
			var t = this;
			for (var i = 0; i < rowsSelected.length; i++) {
				var row = rowsSelected[i];
				var isAdd = true; // 根据现有存在，是否加新行
				for (var j = 0; j < t.c.sonlist.length; j++) {
					if (t.c.sonlist[j].orgid == row.orgid) {
						isAdd = false;
					}
				}
				if (isAdd) {
					t.c.sonlist.push({
						id: "",
						orgid: row.orgid,
						orgName: row.orgNameNew,
						orgNameNew: row.orgNameNew
					});
				}
			}
		},

		getDataAfterCheckbox38: function (rowsSelected, extraData) {
			var t = this;
			for (var i = 0; i < rowsSelected.length; i++) {
				var row = rowsSelected[i];
				var isAdd = true; // 根据现有存在，是否加新行
				for (var j = 0; j < t.c.sonlist.length; j++) {
					if (t.c.sonlist[j].productCode == row.productCode) {
						isAdd = false;
					}
				}
				if (isAdd) {
					t.c.sonlist.push({
						allocateDetailId: row.id,
                		bidAllocate: row.bidAllocate,
                		allocateType: row.typeAllocate,
                		vgsbmFrom: row.vgsbmFrom,
                		vgsjcFrom: row.vgsjcFrom,
                		vgsbmTo: row.vgsbmTo,
                		vgsjcTo: row.vgsjcTo,
						productCode: row.productCode,
						productName: row.productName,
						allocateNum: row.allocateNum,
						distributeNum: row.distributeNum,
						distributedNum: row.canceledNum,
						canceledNum: 0
					});
				}
			}
		},

		getDataAfterCheckbox39: function (rowsSelected, extraData) {
			var t = this;
			for (var i = 0; i < rowsSelected.length; i++) {
				var row = rowsSelected[i];
				var isAdd = true; // 根据现有存在，是否加新行
				for (var j = 0; j < t.c.sonlist.length; j++) {
					if (t.c.sonlist[j].allocateDetailId == row.id) {
						isAdd = false;
					}
				}
				if (isAdd) {
					t.c.sonlist.push({
						allocateDetailId: row.id,
						bidAllocate: row.bidAllocate,
						vgsbmFrom: row.vgsbmFrom,
						vgsjcFrom: row.vgsjcFrom,
						vgsbmTo: row.vgsbmTo,
						vgsjcTo: row.vgsjcTo,
						productCode: row.productCode,
						productName: row.productName,
						depotId: row.depotId,
						depotName: row.depotName,
						allocateNum: row.allocateNum,
						allocateSinglePrice: row.allocateSinglePrice,
						allocateTotalPrice: row.allocateTotalPrice,
						distributedNum: row.distributedNum,
						distributedTotalPrice: row.distributedTotalPrice,
						canceledNum: row.canceledNum,
						mayNum: row.unDistributeNum,
						gdepot: row.depotId,
		            	singlePrice:row.purchaseSinglePrice
					});
				}
			}
		},

		getDataAfterCheckbox43: function (rowsSelected, extraData) {
			var t = this;
			for (var i = 0; i < rowsSelected.length; i++) {
				var row = rowsSelected[i];
				var isAdd = true; // 根据现有存在，是否加新行
				for (var j = 0; j < t.c.sonlist.length; j++) {
					if (t.c.sonlist[j].vremark == row.vReMark) {
						isAdd = false;
					}
				}
				if (isAdd) {
					t.c.sonlist.push({
						id: row.id,
						vid: row.vName,
						vname: row.vAccountName,
						vaccountname: row.vAccount,
						vremark: row.vReMark
					});
				}


			}
		},

		getDataAfterCheckbox44: function (rowsSelected, extraData) {
			var t = this;
			for (var i = 0; i < rowsSelected.length; i++) {
				var row = rowsSelected[i];
				var isAdd = true; // 根据现有存在，是否加新行
				for (var j = 0; j < t.c.sonlist.length; j++) {
					if (t.c.sonlist[j].accountDetailedForCompanyId == row.id) {
						isAdd = false;
					}
				}
				if (isAdd) {
					t.c.sonlist.push({
						accountDetailedForCompanyId: row.id,
						vjylx: row.vjylx,
						vgsjc: row.vgsjc,
						vgsbm: row.vgsbm,
						vgsbmp: row.vgsbmp,
						vgsjcp: row.vgsjcp,
						fje: row.fje,
						djysj: row.djysj,
						dshsj: row.dshsj,
						vbz: row.vbz,
						writeTime: row.writeTime,
					});
				}
			}
		},


		getDataAfterCheckbox47: function (rowsSelected, extraData) {
			var t = this;
			for (var i = 0; i < rowsSelected.length; i++) {
				var row = rowsSelected[i];
				var isAdd = true; // 根据现有存在，是否加新行
				for (var j = 0; j < t.c.sonlist.length; j++) {
					if (t.c.sonlist[j].orderProductComponentId == row.orderProductComponentId) {
						isAdd = false;
					}
				}
				if (isAdd) {
					t.c.sonlist.push({
						id: null,
						purchaseAppointOrderId: row.id,
						orderProductComponentId: row.orderProductComponentId,
						appointOrderBid: row.bid,
						bid:row.bid,
						vname:row.vname,
						vgsbm: row.vgsbm,
						vgsjc: row.vgsjc,
						productCode: row.productCode,
						productName: row.productName,
						codeMerge: row.codeMerge,
						reserveNumber: row.reserveNumber,
						subCode: row.subCode,
						subName: row.subName,
						subCodeMerge: row.subCodeMerge,
						subBomNumber: row.subBomNumber,
						subReserveNumber: row.subReserveNumber,
						subPurchaseNum: row.subReserveNumber,
						subPurchasePrice: row.subBomPrice,
						purchaseTotalPrice:(parseFloat(row.subReserveNumber)*parseFloat(row.subBomPrice)).toFixed(2)
					});
				}
			}


			var contractAmount = 0 ;
			if(t.c.sonlist!=null && t.c.sonlist.length>0){
				for(var i=0;i<t.c.sonlist.length;i++){
					if(t.c.sonlist[i].purchaseTotalPrice){
						contractAmount = contractAmount+parseFloat(t.c.sonlist[i].purchaseTotalPrice);
					}
				}
			}
			var domForm = $('#' + window.formObj.c.id_form);
			//回填合同金额
			domForm.find('input[name="contractAmount"]').val(contractAmount.toFixed(2));
		},

		getDataAfterCheckbox49: function (rowsSelected, extraData) {
			var t = this;
			var isMatching = true; // 主表采购合同单号与子表采购合同单号相同
			for (var i = 0; i < rowsSelected.length; i++) {
				var row = rowsSelected[i];
				var isAdd = true; // 根据现有存在，是否加新行
				for (var j = 0; j < t.c.sonlist.length; j++) {
					if (t.c.sonlist[j].orderProductComponentId == row.orderProductComponentId) {
						isAdd = false;
					}
					var purchaseContractBid = t.c.formObj.getValueByName("purchaseContractBid");
					if (purchaseContractBid != row.purchaseContractBid){
						isMatching = false;
					}
				}
				if (isAdd && isMatching) {
					t.c.sonlist.push({
						purchaseContractItemId: row.purchaseContractItemId,
						purchaseContractBid: row.purchaseContractBid,
						appointOrderBid:row.appointOrderBid,
						vgsbm:row.vgsbm,
						vgsjc:row.vgsjc,
						productCode:row.productCode,
						productName:row.productName,
						accountType:row.accountType,
						codeMerge:row.codeMerge,
						subCode:row.subCode,
						subName:row.subName,
						subCodeMerge:row.subCodeMerge,
						subPurchasePrice:row.subPurchasePrice,
						subBomNumber:row.subBomNumber,
						subNotStorageNum:row.subNotStorageNum,
						preStorageNum:row.subNotStorageNum,
					});
				}
			}
			if (!isMatching){
				layer.msg("主表采购合同单号与子表选择的采购合同单号不相同,请核实后再操作!");
			}
		},

		getDataAfterCheckbox51: function (rowsSelected, extraData) {//预约采购单
			var t = this;

			var _list = [];
			for(var i=0;i<rowsSelected.length;i++){
				_list.push(rowsSelected[i].productCode);
			}
			$.ajax({
				url: '/api/inter/tcgPurchaseAppointOrder/getProductCode',
				data: "productCode="+_list ,
				type: 'POST',
				async: false,
				success: function (res) {
					if (res.code == 0) {
						var data = res.data;
						t.c.sonlist = [];
						for (var i = 0; i < res.data.length; i++) {
							t.c.sonlist.push({
								subCode:res.data[i].code,
								subName:res.data[i].name,
								subBomNumber:res.data[i].num,
								subBomPrice:res.data[i].bprice,
								productCode:res.data[i].productCode,
								productName:res.data[i].productName,
								codeMerge:res.data[i].codeMerge,
								subCodeMerge:res.data[i].subCodeMerge
							});
						}
						t.reloadGrid();

					}

				}
			});

			},


		getDataAfterCheckbox52: function (rowsSelected, extraData) {//发票预核销单
			var t = this;
			for (var i = 0; i < rowsSelected.length; i++) {
				var row = rowsSelected[i];
				var isAdd = true; // 根据现有存在，是否加新行
				for (var j = 0; j < t.c.sonlist.length; j++) {
					if (t.c.sonlist[j].purchaseContractItemId == row.itemId) {
						isAdd = false;
					}
				}
				if (isAdd) {
					t.c.sonlist.push({
						id:'',
						purchaseContractItemId: row.itemId,
						purchaseContractBid: row.bid,
						appointOrderBid: row.appointOrderBid,
						vgsbm: row.vgsbm,
						vgsjc: row.vgsjc,
						vnameByItem: row.vname,
						partnerNameByItem: row.partnerName,
						productCode: row.productCode,
						productName: row.productName,
						codeMerge: row.codeMerge,
						subCode: row.subCode,
						subName: row.subName,
						invoiceModelNo: row.invoiceModelNo,
						invoiceName: row.invoiceName,
						subCodeMerge: row.subCodeMerge,
						subBomNumber: row.subBomNumber,
						subPurchaseNum: row.subPurchaseNum,
						subPurchasePrice: row.subPurchasePrice,
						subWriteOffNum: row.subWriteOffNum,
						offsetNum:0,
						offsetAmount:0
					});
				}
			}

			var offsetTotalAmount = 0 ;
			if(t.c.sonlist!=null && t.c.sonlist.length>0){
				for(var i=0;i<t.c.sonlist.length;i++){
					if(t.c.sonlist[i].offsetAmount){
						offsetTotalAmount = offsetTotalAmount+parseFloat(t.c.sonlist[i].offsetAmount);
					}
				}
			}
			var domForm = $('#' + window.formObj.c.id_form);
			//回填核销总额
			domForm.find('input[name="offsetTotalAmount"]').val(offsetTotalAmount.toFixed(2));

		},

		getDataAfterCheckbox53: function (rowsSelected, extraData) {//采购付款单
			var t = this;
			for (var i = 0; i < rowsSelected.length; i++) {
				var row = rowsSelected[i];
				var isAdd = true; // 根据现有存在，是否加新行
				for (var j = 0; j < t.c.sonlist.length; j++) {
					if (t.c.sonlist[j].purchaseContractItemId == row.purchaseContractItemId) {
						isAdd = false;
					}
				}
				if (isAdd) {
					t.c.sonlist.push({
						id:'',
						purchaseContractItemId: row.purchaseContractItemId,
						purchaseContractBid: row.purchaseContractBid,
						appointOrderBid: row.appointOrderBid,
						companyBankInfoName:row.vname,
						partnerBankInfoName:row.partnerName,
						purchaseAppointOrderBid:row.appointOrderBid,
						vgsbm: row.vgsbm,
						vgsjc: row.vgsjc,
						productCode: row.productCode,
						productName: row.productName,
						codeMerge: row.codeMerge,
						subCode: row.subCode,
						subName: row.subName,
						subCodeMerge: row.subCodeMerge,
						subBomNumber: row.subBomNumber,
						subPurchaseNum: row.subPurchaseNum,
						subPurchasePrice: row.subPurchasePrice,
						purchaseTotalPrice: row.purchaseTotalPrice,
						subPaidNum: row.subPaymentNum,
						subThisPaidNum:row.subPurchaseNum - row.subPaymentNum,
						_ys_CreateTime:row._ys_CreateTime
					});
				}
			}

			var purchasePrice = 0 ;
			var paidAmount = 0 ;
			var currentPaymentAmount = 0 ;
			if(t.c.sonlist!=null && t.c.sonlist.length>0){
				for(var i=0;i<t.c.sonlist.length;i++){
					if(t.c.sonlist[i].subThisPaidNum){
						purchasePrice = purchasePrice+parseFloat(t.c.sonlist[i].subPurchasePrice);
						//（子件已付款数量*子件采购单价）之和
						var subPurchasePrice=parseFloat(t.c.sonlist[i]['subPurchasePrice']);
						var subPaidAmount = (parseFloat(t.c.sonlist[i]['subPaidNum'])* subPurchasePrice).toFixed(2);
						paidAmount = paidAmount + parseFloat(subPaidAmount);
						//（子件本次付款数量*子件采购单价）之和
						var subThisPaidNum = (parseFloat(t.c.sonlist[i]['subThisPaidNum'])* subPurchasePrice).toFixed(2);
						currentPaymentAmount = currentPaymentAmount + parseFloat(subThisPaidNum);
					}
				}
			}
			var domForm = $('#' + window.formObj.c.id_form);
			//回填采购总价
			domForm.find('input[name="purchasePrice"]').val(purchasePrice.toFixed(2));
			//回填已付款金额
			domForm.find('input[name="paidAmount"]').val(paidAmount.toFixed(2));
			//回填本次付款总额
			domForm.find('input[name="currentPaymentAmount"]').val(currentPaymentAmount.toFixed(2));
		},

		getDataAfterCheckbox58: function (rowsSelected, extraData) {//报关单
			var t = this;
			for (var i = 0; i < rowsSelected.length; i++) {
				var row = rowsSelected[i];
				var isAdd = true; // 根据现有存在，是否加新行
				for (var j = 0; j < t.c.sonlist.length; j++) {
					if (t.c.sonlist[j].decCustomSubId == row.decCustomSubId) {
						isAdd = false;
					}
				}
				if (isAdd) {
					row.id = '';
					//本次报关数量 = 子件装箱数量-已报关数量
					row.customsQuantity = parseInt(row.subBoxNum) - parseInt(row.numDecCustom);

					//商品总重 = 商品单重*本次报关数量
					var goodsTotalWeight = 0;
					if(row.singleWeight && row.customsQuantity){
						goodsTotalWeight = (parseFloat(row.singleWeight) * parseFloat(row.customsQuantity)).toFixed(2);
					}
					row.goodsTotalWeight = goodsTotalWeight;

					//销售单价 = 子件采购单价*1.02
					var saleUnitPrice = 0;
					if(row.subPurchasePrice){
						saleUnitPrice = (parseFloat(row.subPurchasePrice) * 0.12).toFixed(2);
					}
					row.saleUnitPrice = saleUnitPrice;

					//销售总价 = 销售单价*本次报关数量
					var saleTotalPrice = 0;
					if(saleUnitPrice && row.customsQuantity){
						saleTotalPrice = (parseFloat(saleUnitPrice) * parseFloat(row.customsQuantity)).toFixed(2);
					}
					row.saleTotalPrice = saleTotalPrice;

					t.c.sonlist.push(row);
				}
			}
			$.ajax({
				url: '/api/inter/tlCustomsDeclaration/getInvoiceDeductionAddInvoice',
				data: {subData:JSON.stringify(t.c.sonlist)} ,
				type: 'POST',
				async: false,
				success: function (res) {
					if (res.code == 0) {
						console.log(1);
						t.c.sonlist = res.resList;
					}
				}
			});





		},



		getDataAfterCheckbox63: function (rowsSelected, extraData) {//采购计划单
			var t = this;
			var codes = '';
			for (var i = 0; i < rowsSelected.length; i++) {
				var row = rowsSelected[i];
				var isAdd = true; // 根据现有存在，是否加新行
				if(t.c.sonlist!=null && t.c.sonlist.length>0){
					for (var j = 0; j < t.c.sonlist.length; j++) {
						if (t.c.sonlist[j].spBm == row.code) {
							isAdd = false;
						}
					}
				}

				if (isAdd) {
					if(codes==''){
						codes = row.code;
					}else {
						codes = codes + ',' +row.code;
					}
				}

			}

			if(codes!=''){
				var domForm = $('#' + window.formObj.c.id_form);
				//运营公司编码
				var vgsbm = domForm.find('input[name="vgsbm"]').val();
				var vgsjc = domForm.find('input[name="vgsjc"]').val();
				$.ajax({
					url: '/api/inter/tcgPurchaseByPlan/getSubInfoByCode',
					data: {codes:codes,vgsbm:vgsbm} ,
					type: 'POST',
					async: false,
					success: function (res) {
						if (res.code == 0) {
							var resList = res.resList;
							if(resList!=null && resList.length>0){
								for (var i = 0; i < resList.length; i++) {
									var resRow = resList[i];
									t.c.sonlist.push({
										spBm:resRow.spBm,
										spName:resRow.spName,
										stockAmount:resRow.stockAmount,
										spAmount:0,
										subCode:resRow.code,
										subName:resRow.name,
										subAmount:resRow.num,
										bprice:resRow.bprice,
										purchaseAmount:0,
										jgSl:0,
										subRemark:resRow.remark,
										subStockAmount:resRow.subStockAmount,
										subTotalPrice:0,
										subTotalAmount:0,
										vgsbmBySub:resRow.vgsbm,
										vgsjcBySub:resRow.vgsjc,
										linkIn:resRow.linkIn,
									})
								}
							}
							var errorMsg = res.errorMsg;
							if(errorMsg!=null && errorMsg!="" && errorMsg.toString().length>0){
								layer.alert(errorMsg);
							}

						}
					}
				});
			}
		},

		getDataAfterCheckbox71: function (rowsSelected, extraData) {//手工组装单
			var t = this;
			var codes = '';
			var domForm = $('#' + window.formObj.c.id_form);
			//组装数量
			var assembleNum = domForm.find('input[name="assembleNum"]').val();
			for (var i = 0; i < rowsSelected.length; i++) {
				var row = rowsSelected[i];
				var isAdd = true; // 根据现有存在，是否加新行
				if(t.c.sonlist!=null && t.c.sonlist.length>0){
					for (var j = 0; j < t.c.sonlist.length; j++) {
						if (t.c.sonlist[j].subCode == row.code) {
							isAdd = false;
						}
					}
				}

				if (isAdd) {
					t.c.sonlist.push({
						productCode:row._ys_pCode,
						subCode:row.code,
						subName:row.name,
						subBomNum:row.num,
						subNeedNum:assembleNum?(parseFloat(assembleNum) * parseFloat(row.num)).toFixed(0):0
					})
				}
			}
		},


		getDataAfterCheckbox72: function (rowsSelected, extraData) {//手工拆装单
			var t = this;
			var codes = '';
			var domForm = $('#' + window.formObj.c.id_form);
			//拆装数量
			var disassembleNum = domForm.find('input[name="disassembleNum"]').val();
			for (var i = 0; i < rowsSelected.length; i++) {
				var row =  rowsSelected[i];
				var isAdd = true; // 根据现有存在，是否加新行
				if(t.c.sonlist!=null && t.c.sonlist.length>0){
					for (var j = 0; j < t.c.sonlist.length; j++) {
						if (t.c.sonlist[j].subCode == row.code) {
							isAdd = false;
						}
					}
				}
				if (isAdd) {
					t.c.sonlist.push({
						productCode:row._ys_pCode,
						subCode:row.code,
						subName:row.name,
						subBomNum:row.num,
						subDisNum:disassembleNum?(parseFloat(disassembleNum) * parseFloat(row.num)).toFixed(0):0
					})
				}
			}
		},



		getDataAfterCheckbox74: function (rowsSelected, extraData) {//库存调拨单
			var t = this;
			for (var i = 0; i < rowsSelected.length; i++) {
				var row = rowsSelected[i];
				var isAdd = true; // 根据现有存在，是否加新行
				if(t.c.sonlist!=null && t.c.sonlist.length>0){
					for (var j = 0; j < t.c.sonlist.length; j++) {
						if (t.c.sonlist[j].stockControlIdByOld == row.id) {

							isAdd = false;
						}
					}
				}
				if (isAdd) {
					t.c.sonlist.push({
						stockControlIdByOld: row.stockControlIdByOld,
						stockControlIdByNewTxt: row.stockControlIdByOld,
						subName: row.productName,
						subCode: row.productCode,
						vgsbmByOld: row.vgsbmByOld,
						vgsjcByOld: row.vgsjcByOld,
						subCodeMerge: row.subCodeMerge,
						productNum: row.productNum,
						productNumAll: row.productNumAll,
						chw: row.chw,
						vck: row.vck,
						vkq: row.vkq,
						vhw: row.vhw,
						companyVid: row.companyVid,
						vname: row.vname,
						rkBid: row.rkBid,
						allocateNum:0,
						productName: row.productName,
						productCode:row.productCode,
					});
				}
			}
		},

		getDataAfterCheckbox76: function (rowsSelected, extraData) {//库存出库
			var t = this;
			for (var i = 0; i < rowsSelected.length; i++) {
				var row = rowsSelected[i];
				var isAdd = true; // 根据现有存在，是否加新行
				if(t.c.sonlist!=null && t.c.sonlist.length>0){
					for (var j = 0; j < t.c.sonlist.length; j++) {
						if (t.c.sonlist[j].controlId == row.id) {

							isAdd = false;
						}
					}
				}
				if (isAdd) {
					t.c.sonlist.push({
						controlId: row.id,
						productName: row.productName,
						productCode: row.productCode,
						codeMerge: row.subCodeMerge,
						productNum: row.productNum,
						productNumAll: row.productNumAll,
						gdepot: row.vck,
						vkq: row.vkq,
						vhw: row.vhw,
						kcdays: row.kcdays,
						vgsbm: row.vgsbmByOld,
						vgsjc: row.vgsjcByOld,
						companyVid: row.companyVid,
						companyVname: row.vname,
						sourceBid:row.rkBid,
					});
				}
			}
		},

		getDataAfterCheckbox77: function (rowsSelected, extraData) {//库存入库
			var t = this;
			for (var i = 0; i < rowsSelected.length; i++) {
				var row = rowsSelected[i];
				var isAdd = true; // 根据现有存在，是否加新行
				if(t.c.sonlist!=null && t.c.sonlist.length>0){
					for (var j = 0; j < t.c.sonlist.length; j++) {
						if (t.c.sonlist[j].code == row.code) {

							isAdd = false;
						}
					}
				}
				if (isAdd) {
					t.c.sonlist.push({
						code: row.code,
						name: row.name
					});
				}
			}
		},
		getDataAfterCheckbox81: function (rowsSelected, extraData) {//HW采购计划
			var t = this;
			for (var i = 0; i < rowsSelected.length; i++) {
				var row = rowsSelected[i];
				var isAdd = true; // 根据现有存在，是否加新行
				if(t.c.sonlist!=null && t.c.sonlist.length>0){
					for (var j = 0; j < t.c.sonlist.length; j++) {
						if (t.c.sonlist[j].code == row.code) {

							isAdd = false;
						}
					}
				}
				if (isAdd) {
					t.c.sonlist.push({
						row
					});
				}
			}
		},
		getDataAfterCheckbox78: function (rowsSelected, extraData) {
			var t = this;
			var domForm = $('#' + window.formObj.c.id_form);

			for (var i = 0; i < rowsSelected.length; i++) {
				var row = rowsSelected[i];
				var isAdd = true; // 根据现有存在，是否加新行
				for (var j = 0; j < t.c.sonlist.length; j++) {
					if (t.c.sonlist[j].stockControlId == row.stockControlId) {
						isAdd = false;
					}
				}
				if (isAdd) {
					t.c.sonlist.push({
						id:null,
						commodityCode:row.commodityCode,
						commodityName:row.commodityName,
						sku:row.sku,
						numStock:row.numStock,
						numPlanDeliver:row.numStock,
						isSign:row.isSign,
						signCode:row.signCode,
						asin:row.asin,
						fnSku:row.fnSku,
						codeGoodsHs:row.codeGoodsHs,
						nameGoodsCn:row.nameGoodsCn,
						nameMaterialCn:row.nameMaterialCn,
						nameUnitCn:row.nameUnitCn,
						priceIn:row.priceIn,
						lengthPackage:row.lengthPackage,
						widthPackage:row.widthPackage,
						heightPackage:row.heightPackage,
						packageSize:row.packageSize,
						// weightPackage:(row.weightPackage/1000).toFixed(2),
						weightPackage:row.weightPackage,
						vck:row.vck,
						vkq:row.vkq,
						vhw:row.vhw,
						chw:row.chw,
						declarationItemState:row.declarationState,
						declarationItemStateName:row.declarationStateName,
						stockControlId:row.stockControlId,
						amazonShopProductId:row.amazonShopProductId,
					});
				}
			}

			if (t.c.sonlist.length > 0){
				domForm.find('input[name="declarationState"]').val(t.c.sonlist[0].declarationItemState);
				domForm.find('input[name="declarationStateName"]').val(t.c.sonlist[0].declarationItemStateName);
			}
		},


		getDataAfterCheckbox89: function (rowsSelected, extraData) {//物流付款单（关税费）
			var t = this;
			for (var i = 0; i < rowsSelected.length; i++) {
				var row = rowsSelected[i];
				var isAdd = true; // 根据现有存在，是否加新行
				if(t.c.sonlist!=null && t.c.sonlist.length>0){
					for (var j = 0; j < t.c.sonlist.length; j++) {
						if (t.c.sonlist[j].logisticsComprehensiveId == row.logisticsComprehensiveId) {
							isAdd = false;
						}
					}
				}
				if (isAdd) {
					t.c.sonlist.push({
						row
					});
				}
			}

			//计算总金额
			var amount = 0 ;//总金额
			if(t.c.sonlist!=null && t.c.sonlist.length>0){
				for(var i=0;i<t.c.sonlist.length;i++){
					if(t.c.sonlist[i].payAmount){
						amount = amount+parseFloat(t.c.sonlist[i].payAmount);
					}
				}
			}
			var domForm = $('#' + window.formObj.c.id_form);
			//回填总金额
			domForm.find('input[name="totalAmount"]').val(amount.toFixed(2));

		},

		getDataAfterCheckbox90: function (rowsSelected, extraData) {//物流付款单（物流费）
			var t = this;
			for (var i = 0; i < rowsSelected.length; i++) {
				var row = rowsSelected[i];
				var isAdd = true; // 根据现有存在，是否加新行
				if(t.c.sonlist!=null && t.c.sonlist.length>0){
					for (var j = 0; j < t.c.sonlist.length; j++) {
						if (t.c.sonlist[j].logisticsComprehensiveId == row.logisticsComprehensiveId) {
							isAdd = false;
						}
					}
				}
				if (isAdd) {
					t.c.sonlist.push({
						row
					});
				}
			}

			//计算总金额
			var amount = 0 ;//总金额
			if(t.c.sonlist!=null && t.c.sonlist.length>0){
				for(var i=0;i<t.c.sonlist.length;i++){
					if(t.c.sonlist[i].payAmount){
						amount = amount+parseFloat(t.c.sonlist[i].payAmount);
					}
				}
			}
			var domForm = $('#' + window.formObj.c.id_form);
			//回填总金额
			domForm.find('input[name="totalAmount"]').val(amount.toFixed(2));

		},






		removeRow:function (index) { // 重新加载表格
        	var t = this;
        	t.c.sonlist.splice(index, 1);
			t.reloadGrid();
			return;
        },
        removeRowsChecked:function () { // 移除选中的行
        	var t = this;
			var checkStatus = layui.table.checkStatus(t.c.id_table_sub);
			var checkedDatas = checkStatus.data;
			for (var i = checkedDatas.length - 1; i >= 0; i--) {
				var index = checkedDatas[i]['_ys_sub_grid_index'];
	        	t.c.sonlist.splice(index, 1);
			}
			
			t.reloadGrid();
			return;
        },
        getData:function () {
            return this.c.sonlist;
        },
        init:function (c) {this.f(c);this.load();return object;
			if(c.callback && typeof c.callback === 'function') {
				c.callback();
			}
		},
        reload:function (c) {c.data = this.c.data;$('#' + this.c.id).empty();return this.init(c);},
        addRow:function (row) {
        	var c = this.c;
        	c.sonlist.push(row);
        	$('#' + c.id).empty();
        	return this.reload(c);
        },
        addRows:function (rows) {
        	var c = this.c;
        	for (var i = 0; i < rows.length; i++) {
	        	c.sonlist.push(rows[i]);
			}
        	$('#' + c.id).empty();
        	return this.reload(c);
        },
        clearRows:function (rows) {
        	var c = this.c;
        	c.sonlist = [];
        	$('#' + c.id).empty();
        	return this.reload(c);
        },
        editRow:function (index, row) {
        	var c = this.c;
			c.data[index] = row;
        	$('#' + c.id).empty();
        	return this.reload(c);
        },
        editRowOfAttr:function (index, row) {
        	var c = this.c;
        	for(var key in row){
        		c.data[index][key] = row[key]
        	}
        	$('#' + c.id).empty();
        	return this.reload(c);
        },
		//重写toFixed方法
		toFixed:function(number, precision) {
			if (Number.isInteger(Number(number))) {
				return number;
			}
			number = Math.round(+number + 'e' + precision) / Math.pow(10, precision) + '';
			let s = number.split('.');
			if ((s[1] || '').length < precision) {
				s[1] = s[1] || '';
				s[1] += new Array(precision - s[1].length).fill('0').join('');
			}
			return s.join('.');
		},
        //行合并 start
        execRadioRows:function (childFilterArr, ckChildFilterArr, flag) {
            //获取td的个数和种类
            var chChildFilterTextObj = {};
            var chText = [];
            var chIndex = [];

            for (var i = 0; i < ckChildFilterArr.length; i++) {
                var chChildText = flag ? ckChildFilterArr[i].innerHTML : ckChildFilterArr[i].textContent;
                if (chChildFilterTextObj[chChildText] == undefined) {
                    chChildFilterTextObj[chChildText] = 1;
                    chText.push(chChildText);
                } else {
                    var num = chChildFilterTextObj[chChildText];
                    chChildFilterTextObj[chChildText] = num * 1 + 1;
                }
            }
            for (var i = 0; i < chText.length; i++) {
                var chNum = 0;
                for (var j = 0; j < ckChildFilterArr.length; j++) {
                    var chChildText = flag ? ckChildFilterArr[j].innerHTML : ckChildFilterArr[j].textContent;
                    if (chText[i] == chChildText) {
                        chNum = chNum + 1
                    }
                }
                chIndex.push(chNum);
            }
            var newIndex = [];
            for (var i = 0; i < chIndex.length; i++) {
                if (i == 0) {
                    newIndex.push(0);
                } else {
                    var newNum = 0;
                    for (var j = 0; j < chIndex.length; j++) {
                        if (j < i) {
                            newNum = newNum + chIndex[j];
                        }
                    }
                    newIndex.push(newNum);
                }
            }
            chIndex = newIndex;

            for (var j = 0; j < childFilterArr.length; j++) {
                var findFlag = false;
                for (var k = 0; k < chIndex.length; k++) {
                    if (j == chIndex[k]) {
                        findFlag = true;
                        if (chIndex[k + 1] != null) {
                            childFilterArr[j].setAttribute("rowspan", chIndex[k + 1] - j);
                            $(childFilterArr[j]).find("div.rowspan").parent("div.layui-table-cell").addClass("rowspanParent");
                            $(childFilterArr[j]).find("div.layui-table-cell")[0].style.height = (chIndex[k + 1] - j) * 38 - 10 + "px";

                        } else {
                            childFilterArr[j].setAttribute("rowspan", childFilterArr.length - j);
                            $(childFilterArr[j]).find("div.rowspan").parent("div.layui-table-cell").addClass("rowspanParent");
                            $(childFilterArr[j]).find("div.layui-table-cell")[0].style.height = (childFilterArr.length - j) * 38 - 10 + "px";
                        }
                    }
                }
                if (findFlag == false) {
                    childFilterArr[j].style.display = "none";
                }
            }
        },
        execRowspan:function(fieldName, index, flag, ckRows) {
            var fixedNode = $(".layui-table-body")[index];
            var child = $(fixedNode).find("td");
            var childFilterArr = [];
            for (var j = 0; j < child.length; j++) {
                child[j].getAttribute('data-field')
                if (child[j].getAttribute("data-field") == fieldName) {
                    childFilterArr.push(child[j]);
                }
            }

            var ckChildFilterArr = [];
            if (fieldName == "0") {
                for (var j = 0; j < child.length; j++) {
                    child[j].getAttribute('data-field')
                    if (child[j].getAttribute("data-field") == ckRows) {
                        ckChildFilterArr.push(child[j]);
                    }
                }
                this.execRadioRows(childFilterArr, ckChildFilterArr, flag);
                return;
            }

            //获取td的个数和种类
            var childFilterTextObj = {};
            for (var i = 0; i < childFilterArr.length; i++) {
                var childText = flag ? childFilterArr[i].innerHTML : childFilterArr[i].textContent;
                if (childFilterTextObj[childText] == undefined) {
                    childFilterTextObj[childText] = 1;
                } else {
                    var num = childFilterTextObj[childText];
                    childFilterTextObj[childText] = num * 1 + 1;
                }
            }
            var canRowspan = true;
            var maxNum;//以前列单元格为基础获取的最大合并数
            var finalNextIndex;//获取其下第一个不合并单元格的index
            var finalNextKey;//获取其下第一个不合并单元格的值
            for (var i = 0; i < childFilterArr.length; i++) {
                (maxNum > 9000 || !maxNum) && (maxNum = $(childFilterArr[i]).prev().attr("rowspan") && fieldName != "8" ? $(childFilterArr[i]).prev().attr("rowspan") : 9999);
                var key = flag ? childFilterArr[i].innerHTML : childFilterArr[i].textContent;//获取下一个单元格的值
                var nextIndex = i + 1;
                var tdNum = childFilterTextObj[key];
                var curNum = maxNum < tdNum ? maxNum : tdNum;
                if (canRowspan) {
                    for (var j = 1; j <= curNum && (i + j < childFilterArr.length);) {//循环获取最终合并数及finalNext的index和key
                        finalNextKey = flag ? childFilterArr[i + j].innerHTML : childFilterArr[i + j].textContent;
                        finalNextIndex = i + j;
                        if ((key != finalNextKey && curNum > 1) || maxNum == j) {
                            canRowspan = true;
                            curNum = j;
                            break;
                        }
                        j++;
                        if ((i + j) == childFilterArr.length) {
                            finalNextKey = undefined;
                            finalNextIndex = i + j;
                            break;
                        }
                    }
                    childFilterArr[i].setAttribute("rowspan", curNum);
                    if ($(childFilterArr[i]).find("div.rowspan").length > 0) {//设置td内的div.rowspan高度适应合并后的高度
                        $(childFilterArr[i]).find("div.rowspan").parent("div.layui-table-cell").addClass("rowspanParent");
                        $(childFilterArr[i]).find("div.layui-table-cell")[0].style.height = curNum * 38 - 10 + "px";
                    }
                    canRowspan = false;
                } else {
                    childFilterArr[i].style.display = "none";
                }
                if (--childFilterTextObj[key] == 0 | --maxNum == 0 | --curNum == 0 | (finalNextKey != undefined && nextIndex == finalNextIndex)) {
                    canRowspan = true;
                }
            }
        },
         layuiRowspan:function(fieldNameTmp, index, flag, ckRows) {
                var fieldName = [];
                if (typeof fieldNameTmp == "string") {
                    fieldName.push(fieldNameTmp);
                } else {
                    fieldName = fieldName.concat(fieldNameTmp);
                }
                for (var i = 0; i < fieldName.length; i++) {
                    this.execRowspan(fieldName[i], index, flag, ckRows);
                }
        },
		//行合并 end
		opeTplScript:function(d) {
			console.log('---------d---------',d);
			var t = this;
			console.log('---------gridId---------',t.c.gridId);
			if(t.c.gridId == 15) {

			}
		}

	};
	exports('YsSubGrid', object);
});

function ysFormOfSubGridRemoveFile(obj) {
	var domThis = $(obj);
	var labelName = domThis.attr('label');
	var domParent = domThis.parent();
	// 隐藏删除按钮
	domParent.find('button[data-event-name="remove-file"]').hide();
	// 隐藏下载按钮
	domParent.find('button[data-event-name="download-file"]').hide();
	
	// 表单值清空
	domParent.find('input[name="' + labelName + '"]').val('');
	
	// 图标恢复上传前
	domParent.find('img').attr('src', '/static/img/img_add.jpg');
}

